0

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>

2 Answers 2

1

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);
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.