> <C# programming> How can I get string values from attributes of XML without knowing elements names?

<C# programming> How can I get string values from attributes of XML without knowing elements names?

Posted at: 2014-12-18 
Using an xpath query such as "*[@attributename]"

Will give you all the elements containing the attribute "attributename"...

Try using an xml editor and running an query.

I'm learning C# and working on dealing with XML.

At least I know that string values of attributes can be retrieved by the following coding.

XmlDocument doc = new XmlDocument();

doc.Load("path to your file");

XmlAttribute a = doc.SelectSingleNode("/elementNames/@attributeNames");

However, if i don't know any element name which is associated with the attribute, how can I get the strings of the attributes?