Get specific data from XML document
I have xml document like this:


    <level1>
     <level2>
      <level3>
       <attribute1>...</attribute1>
       <attribute2>false</attribute2>
       <attribute3>...</attribute3>
      </level3>
      <level3>
       <attribute1>...</attribute1>
       <attribute2>true</attribute2>
       <attribute3>...</attribute3>
      </level3>
    </level2>
    <level2>
     <level3>
       <attribute1>...</attribute1>
       <attribute2>false</attribute2>
    ...
    ...
    ...

 

 
I'm using c#, and I want to go thru all "level3", and for every "level3", i want to read attribute2, and if it says "true", i want to print the corresponding attribute3 (can be "level3" without these attributes).
 
I keep the xml in XmlDocument.
Then I keep all the "level3" nodes like this:

    XmlNodeList xnList = document.SelectNodes(String.Format("/level1/level2/level3"));

 
(document is the XmlDocument).
 
But from now on, I don't know exactly how to continue. I tried going thru xnList with for..each, but nothing works fine for me..

How can I do it?
 
Thanks a lot 
Get specific data from XML document
===

I have xml document like this:


    <level1>
     <level2>
      <level3>
       <attribute1>...</attribute1>
       <attribute2>false</attribute2>
       <attribute3>...</attribute3>
      </level3>
      <level3>
       <attribute1>...</attribute1>
       <attribute2>true</attribute2>
       <attribute3>...</attribute3>
      </level3>
    </level2>
    <level2>
     <level3>
       <attribute1>...</attribute1>
       <attribute2>false</attribute2>
    ...
    ...
    ...

 

 
I'm using c#, and I want to go thru all "level3", and for every "level3", i want to read attribute2, and if it says "true", i want to print the corresponding attribute3 (can be "level3" without these attributes).
 
I keep the xml in XmlDocument.
Then I keep all the "level3" nodes like this:

    XmlNodeList xnList = document.SelectNodes(String.Format("/level1/level2/level3"));

 
(document is the XmlDocument).
 
But from now on, I don't know exactly how to continue. I tried going thru xnList with for..each, but nothing works fine for me..

How can I do it?
 
Thanks a lot 