Getting nodes from an XML-document

K

Klaus Jensen

Hi

Using Xml.XmlDocument I need to get all <rfd:li>-elements below
<photoshop:SupplementalCategories> in the below XML-sample.

I normally use GetElementsByTagName, but since there are other <rfd:id>
elements other places in the doc, I cant.

How do I navigate the tree and get the right nodes?

<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="3.1.1-112">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
<crs:ToneCurve>
<rdf:Seq>
<rdf:li>0, 0</rdf:li>
<rdf:li>32, 22</rdf:li>
<rdf:li>64, 56</rdf:li>
<rdf:li>128, 128</rdf:li>
<rdf:li>192, 196</rdf:li>
<rdf:li>255, 255</rdf:li>
</rdf:Seq>
</crs:ToneCurve>
<photoshop:SupplementalCategories>
<rdf:Bag>
<rdf:li>Category 1</rdf:li>
<rdf:li>Category 2</rdf:li>
<rdf:li>Category 3</rdf:li>
</rdf:Bag>
</photoshop:SupplementalCategories>
</rdf:Description>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>

Norm
 
Z

zacks

Klaus said:
Hi

Using Xml.XmlDocument I need to get all <rfd:li>-elements below
<photoshop:SupplementalCategories> in the below XML-sample.

I normally use GetElementsByTagName, but since there are other <rfd:id>
elements other places in the doc, I cant.

How do I navigate the tree and get the right nodes?

<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="3.1.1-112">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
<crs:ToneCurve>
<rdf:Seq>
<rdf:li>0, 0</rdf:li>
<rdf:li>32, 22</rdf:li>
<rdf:li>64, 56</rdf:li>
<rdf:li>128, 128</rdf:li>
<rdf:li>192, 196</rdf:li>
<rdf:li>255, 255</rdf:li>
</rdf:Seq>
</crs:ToneCurve>
<photoshop:SupplementalCategories>
<rdf:Bag>
<rdf:li>Category 1</rdf:li>
<rdf:li>Category 2</rdf:li>
<rdf:li>Category 3</rdf:li>
</rdf:Bag>
</photoshop:SupplementalCategories>
</rdf:Description>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>

Norm

You need to use the GetChilds method to load the list of child nodes
into a NodeList and then do a ForEach on the NodeList to parse through
the children.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Write Attribute to an .xmp (xml) File 0
RSS - XML 3

Top