开发者

How to walk across XmlNode in VB.NET 2008

开发者 https://www.devze.com 2022-12-09 02:43 出处:网络
I need to walk or interact across all nodes and child nodes with VB.NET 200开发者_运维技巧8 and display thru debug.print.

I need to walk or interact across all nodes and child nodes with VB.NET 200开发者_运维技巧8 and display thru debug.print.

Thanks.


Try it,

XmlDocument itemDoc = new XmlDocument();
itemDoc.Load("file.xml");
Console.WriteLine("DocumentElement has {0} children.",
itemDoc.DocumentElement.ChildNodes.Count);

foreach (XmlNode itemNode in itemDoc.DocumentElement.ChildNodes){
    XmlElement itemElement = (XmlElement)itemNode;
    Console.WriteLine("\n[Item]: {0}\n{1}", 
        itemElement.Attributes["name"].Value,
        itemElement.Attributes["description"].Value);
    if (itemNode.ChildNodes.Count == 0)
        Console.WriteLine("(No additional Information)\n");
    else
    {
        foreach (XmlNode childNode in itemNode.ChildNodes){
           // 
        }               
    }
}
0

精彩评论

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