Hello everybody,
I'm trying to parse a XML stream coming from a DLNA server using the XOM library, everything works ok except in one case:
When there are two nodes with the same name (in my case: <res> ... </res> wich are in the same name-space (in my case: "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"), my question is how can I get the value of the second <res> node.
A part of the XML stream:
The part of the working code, which parses only the 1rst occurence of <res> node:
My question is how can I get the value of the second <res> node ?
Any help or track are welcome!
I'm trying to parse a XML stream coming from a DLNA server using the XOM library, everything works ok except in one case:
When there are two nodes with the same name (in my case: <res> ... </res> wich are in the same name-space (in my case: "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"), my question is how can I get the value of the second <res> node.
A part of the XML stream:
XML stream:
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<u:BrowseResponse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
<Result><DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/">
<item id="64$0$0$0" parentID="64$0$0" restricted="1">
<dc:title>L'ennemi intime</dc:title>
<upnp:class>object.item.videoItem</upnp:class><dc:date>2017-11-18T08:03:56</dc:date>
<res size="1527814311"duration="1:46:05.00bitrate="240033"sampleFrequency="48000"nrAudioChannels="2"resolution="960x540"
protocolInfo="httpget:*:video/mp4:DLNA.ORG_PN=AVC_MP4_BL_L31_HD_AAC;DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000">http://192.168.1.8:8200/MediaItems/24.mp4</res>
<res protocolInfo="http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_TN">http://192.168.1.8:8200/AlbumArt/2-24.jpg</res>
</item>
....
....
....
The part of the working code, which parses only the 1rst occurence of <res> node:
Working code:
For i = 0 To containerNodes.Size - 1
' Initialise container to store item details
Dim container As itemContainer
container.Initialize
' Get title value
Dim containerNode As XOMElement = containerNodes.GetElement(i)
' Store container id (Unique key to access the item)
Dim key As String
key = containerNode.GetAttributeByName("id").Value
Dim nameSpace As String = "http://purl.org/dc/elements/1.1/"
Dim titleNode As XOMElement = containerNode.GetFirstChildElementByNameAndNamespace("title", nameSpace)
container.title = titleNode.Value
' Get class value
Dim nameSpace As String = "urn:schemas-upnp-org:metadata-1-0/upnp/"
Dim classNode As XOMElement = containerNode.GetFirstChildElementByNameAndNamespace("class", nameSpace)
container.itemClass = classNode.Value
' Get res value (location to stream content)
Dim nameSpace As String = "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"
Dim resNode As XOMElement = containerNode.GetFirstChildElementByNameAndNamespace("res", nameSpace)
If resNode.IsInitialized Then
container.location = resNode.Value
' Attempt to get resolution information
Try
container.strResolution = resNode.GetAttributeByName("resolution").Value
Catch
Log("xxx- Resolution unavailable -xxx")
End Try
Else
container.location = ""
' Store id and container info in browseResults list (ignore trailers)
If titleNode.Value.ToLowerCase.Contains("-trailer") = False Then
UPNP.browseResults.Put(key, container)
End If
Next
My question is how can I get the value of the second <res> node ?
Any help or track are welcome!