tags:

views:

71

answers:

2

Hello,

I have the following XML code, which I got by a UPnP device and like to get the res value - the RTSP URL. In this case rtsp://10.42.0.103:554/live.sdp

How can I do this? I heard that Android has some built-in support for reading XML. Is that true?

<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/">
<item id="11" parentID="1" restricted="1">
<dc:title>Network Camera Stream 1</dc:title>
<upnp:class>object.item.videoItem</upnp:class>
<res protocolInfo="rtsp-rtp-udp:*:video/mpeg4-generic:*" resolution="640x480">rtsp://10.42.0.103:554/live.sdp</res>
</item>
<item id="12" parentID="1" restricted="1">
<dc:title>Network Camera Stream 2</dc:title>
<upnp:class>object.item.videoItem</upnp:class>
<res protocolInfo="rtsp-rtp-udp:*:video/mpeg4-generic:*" resolution="176x144">rtsp://10.42.0.103:554/live2.sdp</res>
</item>
</DIDL-Lite>
+1  A: 

You may probably be looking for a SAX-Parser:
http://developer.android.com/reference/javax/xml/parsers/SAXParser.html

SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
parser.parse(xml, yourXMLHandler);
Mannaz
A: 

Well, thanks for your help. SAX is in my opinion too much overhead for this small file. It's much easier with an XMLPullParser ... you don't have to deal with this event stuff and can quickly pick up some keywords ...

http://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html

Nils