Sunday, August 1, 2010

[android-developers] Re: Retrieving XML Document from web service

I dont know if it is suitable for your case, but I can retrieve the
xml document for the web with the following method

URL mURL= new URL("http://XXXXX/a.xml");
http = (HttpURLConnection) mURL.openConnection();
int nRC = http.getResponseCode();
if (nRC == HttpURLConnection.HTTP_OK)
{
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document dom = builder.parse(mURL.openConnection().getInputStream());
Element root = dom.getDocumentElement();
NodeList items = root.getElementsByTagName("item");
for(int i=0; i<items.getLength(); i++)
{
Node property = properties.item(j);
String name = property.getNodeName();
if (name.equalsIgnoreCase("property1))
{
Log.d("Property1", property.getFirstChild().getNodeValue());
}
}
}

//a.xml
<root>
<item>
<property1>Iamproperty1</property1>
</item>
</root>

On Jul 31, 6:35 am, beacon <indiantalkiedhi...@gmail.com> wrote:
> Hi ,
>
>  I am trying to retrieve a XML document from web service. I am passing
> a soap object with a token implementing the OAuth concept and
> retrieving the data. But the data does not turn out to be in XML
> format. It contains a curly braces in the place of start tag and
> semicolons when it ends. Is there any way to retrieve the document in
> XML format as such?
>
> Thank you
>
> Beacon

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate