sachi vasishta

sachi vasishta

  • NA
  • 252
  • 0

How to read XML attribute values ?

Nov 21 2011 5:25 AM
 Hi All,

How to read a XML attribute value in C# ?

I have a XML doc as below stored in a file called Auto.xml in the same path as that of the solution.

<root>
  <fault category="pending">
    <text>Pending Fault found on</text>
  </fault>
  <fault category="repaired">
    <text>Repaired Fault on</text>
  </fault>
  <genere>
    <text1>Aircraft</text1>
    <text2>Component</text2>
    <text3>Subsystem</text3>
  </genere>
</root>

Now I want to check the node type, i.e., if the node type is attribute and if the attribute value is "pending" then I want to return the corresponding text node value "Pending Fault found on" as a string array. But I don't know how to read the attribute value of a node.

(I am using VS 2008)

Thanks,
Sachi

Answers (7)