Hi all,
I have the following code:
protected void Page_Load(object sender, EventArgs e)
{
XElement xml = XElement.Load(Server.MapPath("ArenasMembers.xml"));
var query = from p in xml.Descendants("members")
select new
{
Name = p.Element("name").Value,
Email = p.Attribute("email").Value
};
foreach (var member in query)
{
Response.Write("Employee: " + member.Name + " " + member.Email + "<br />");
}
}
Which, using the hover information in Visual Studio, is reading the XNL file in correctly, however the
foreach is not outputting any of the records.
XML:
<?xml version="1.0" encoding="utf-8" ?>
<members>
<member>
<arena>EAA Office</arena>
<memberid>1</memberid>
<name>Jane Doe</name>
<email>
[email protected]</email>
</member>
<member>
<arena>EAA Office</arena>
<memberid>2</memberid>
<name>John Bull</name>
<email>
[email protected]</email>
</member>
<member>
<arena>O2 Arena</arena>
<memberid>3</memberid>
<name>John Doe</name>
<email>
[email protected]</email>
</member>
<member>
<arena>O2 Arena</arena>
<memberid>4</memberid>
<name>Bernard Cribbins</name>
<email>
[email protected]</email>
</member>
<member>
<arena>Colourline Arena</arena>
<memberid>5</memberid>
<name>John Bon Jovi</name>
<email>
[email protected]</email>
</member>
<member>
<arena>NIA</arena>
<memberid>6</memberid>
<name>Rhianna</name>
<email>
[email protected]</email>
</member>
</members>
Can you see what is wrong?