Again since I cant post a reply to “XML help, please” there I post it here
- simply walk the list of nodes knowing the structure. this can be problematic at times though
- XQL can be used in a few ways. For instance :
assuming sampleXML looks like
<?xml version="1.0" encoding="UTF-8"?>
<assets>
<asset id="r2" name="00018M" uid="DF36C3050CEDE81F705DC99FCF0E1487">
<media-rep kind="original-media" sig="DF36C3050CEDE81F705DC99FCF0E1487" src="file:///Volumes/Storage2/00018M.MXF">
</media-rep>
<metadata>
<md key="com.apple.rawToLogConversion" value="0"/>
<md key="com.apple.kMDItemProfileName" value="SD (6-1-6)"/>
</metadata>
</asset>
<asset id="r3" name="00019M" uid="1">
<media-rep kind="original-media" sig="D" src="file:///Volumes/Storage_45/00019M.MXF">
</media-rep>
<metadata>
<md key="com.apple.rawToLogConversion" value="0"/>
<md key="com.apple.kMDItemProfileName" value="SD (6-1-6)"/>
</metadata>
</asset>
</assets>
then code as follows will work
Dim xmlDoc As New XmlDocument(sampleXML)
Dim docNode As XmlNode = xmlDoc.DocumentElement
// find all assets that are at the top level
Dim assets As XmlNodeList = docNode.XQL("//asset")
For i As Integer = 0 To assets.Length - 1
Dim currentAsset As XmlNode = assets.Item(i)
// now we want the media-rep nodes
// maybe there's one or more ?
// note we do not use // as we just want the ones that are in THIS node
Dim mediaRep As XmlNodeList = currentAsset.XQL("media-rep")
For j As Integer = 0 To mediaRep.Length - 1
Dim currentmediaRep As XMLNode = mediaRep.item(j)
// print the src attribute
System.debuglog currentmediaRep.GetAttribute("src")
Next
Next