Hi,

I am really new at ASP.NET, and I am wondering if there is a good way to extract XML attributes from ASP.NET. The example I am reading is here: http://www.w3schools.com/aspnet/aspnet_datalist.asp

Suppose I fix the XML snippet to:

<catalog>
<cd>
  <title>Eros</title>
  <artist country="EU">Eros Ramazzotti</artist>
  <company>BMG</company>
  <price>9.90</price>
  <year>1997</year>
</cd>
</catalog>

What should I change <%#Container.DataItem("artist")%> to in order to print out the country attribute?

Thanks for your help.

XmlDocument doc = new XmlDocument();
        doc.Load(Server.MapPath("~/XMLFile.xml"));

        XmlNodeList mynodes = doc.SelectNodes("article/body/page");
        
        foreach (XmlNode node in mynodes)
        {
            Response.Write(node.InnerText.ToString());
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.