开发者

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;
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜