tags:

views:

66

answers:

1

This is the XML file:

<?xml version="1.0" encoding="utf-8" ?>
<Books>
    <Book id="1">
     <Author>Mark</Author>
     <Publisher>Sams</Publisher>
    </Book>
</Books>

This is the code to extract the attribute:

 XmlTextReader textReader = new XmlTextReader("D:\\books.xml");
            textReader.MoveToElement();
            string au = textReader.GetAttribute("Auther");
            Uname.Text = au;
+3  A: 

Author is not an Attribute, it is an Element of the Element Book.

I think you need some basics of XML first, before you start parsing it.

e.g. http://www.w3schools.com/xmL/

What might help also is looking into XPath. It helps you in selecting Elements. This is helpful especially if you already know the structure of the XML you'd like to parse.

StampedeXV