开发者

how to display xml content

开发者 https://www.devze.com 2023-02-04 20:47 出处:网络
i have an xml file with the following content <root> <books> <foo> mathew </foo> </开发者_如何学运维books>

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

精彩评论

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