Suppose I have the following XML Document.
<reply success="true">More nodes go here</reply>
How to get the value of the attribute success, which in this case would be the string "true".
Suppose I have the following XML Document.
<reply success="true">More nodes go here</reply>
How to get the value of the attribute success, which in this case would be the string "true".
string x="<node1 id='12345'><node2 Name='John'></node2><node3 name='abc'></node3></node1>";
XmlDocument xml = new XmlDocument();
xml.LoadXml(x);
var node = xml.GetElementsByTagName("node3");
xml = new XmlDocument();
xml.LoadXml(nodes[0].OuterXml);
XmlElement root = xml.DocumentElement;
String requiredValue = root.GetAttribute("name");
returns "abc";