Using C# I have an XML file like
<?xml version="1.0" encoding="utf-8"?>
XmlDocument xmlDoc = new XmlDocument();
node = xmlDoc.DocumentElement;
string name = node.Attributes.Value;
label1.Text = name.ToString();
node = xmlDoc.DocumentElement; string name = node.Attributes.Value;
node is your root node. Which looks like this:
How many attributes does it have? None, as it turns out. An attribute in XML is one of these
node.Attributes refers to the first attribute. There is no first attribute, there's no second attribute -- you didn't use attributes in this XML at all. Hence, that's out of range. There's no first item in an empty collection.
What you want is an element named
name, which is farther down inside your XML tree.
var node = xmlDoc.DocumentElement.SelectSingleNode("/root/Account/name");
And then you'll want to look at
node.InnerText to get
"Jani" out of it.