Home All Groups Group Topic Archive Search About

Getting nodes from an XML-document

Author
27 Sep 2006 10:22 AM
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

Author
27 Sep 2006 2:24 PM
zacks
Klaus Jensen wrote:
Show quoteHide quote
> 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.