how to display xml content
i have an xml file with the following content
<root>
<books>
<foo>
mathew
</foo>
</开发者_如何学运维books>
</root>
i want to display the content mathew in a label How can i do that
If the contents of the XML file is that basic as in your sample and the label is called Label1
, you could manage with something like this:
XmlTextReader reader = new XmlTextReader(xmlFilePath);
while(reader.Read())
{
if(reader.NodeType == XmlNodeType.Element && reader.Name == "foo")
{
reader.Read();
Label1.Text = reader.Value;
}
}
精彩评论