My XML looks like this:
<product id="1">
<name>A thing</name>
<description>This is what it's like</description>
</product>
I’ve been looking for an example that might look something like this:
string productID = 1;
XDocument productsXML = XDocument.Load("Products.xml");
for item in productsXML {
if (item.ID == productID) {
productNameLabel.Text = item.name;
}
}
The idea being, I’ll be able to output a single xml child element to the .aspx page.
A thing
Does that make sense? I’ve been looking for examples for a few hours, and I’m starting to think that there is lot more scaffolding that I need, but since all the examples are so different, I’m not sure which one to follow!
So, how can I grab the contents of a single XML child element, and output it to the .aspx? Take this:
<product id="1">
<name>A thing</name>
<description>This is what it's like</description
</product>
and output this:
A thing
You can use XPath (in
System.Xml.XPath)