sending xml file from php to an android application
-
28-10-2019 - |
سؤال
I am trying to send an xml file as a httpresponse to a post from an android application.
I understood how to send data from a php page here.
Is it possible to send a xml file as a response?
Or do I have to send the content of xml file as a string and parse it in the application?
If it is possible, How do I read the file in my application, so that I can parse it for information?
Thank you.
المحلول
Send the xml from the server as a string. And in the application side parse the string either using SaxParser, XmlPullParser or DomParser. These are all commonly used.
This is a tutorial from IBM which gives an overview of parsing in android http://www.ibm.com/developerworks/opensource/library/x-android/index.html
نصائح أخرى
Of course you can. just you can send the xml format type in a php source file.
like following code. sorry for writing [ instead of < or > as this post doesn't allow tag elements.
echo '[?xml version="1.0" encoding="utf-8"?]'; echo '[something][/something]';