Get All node name in xml in silverlight

后端 未结 2 952
梦谈多话
梦谈多话 2021-01-17 06:57

i created one xml like this



nixon


i want iterate each node name by foreach loop or

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-17 07:30

    You can use the DescendantsAndSelf() method of XElement to get all the nodes and their names.

    foreach (XElement child in doc.Root.DescendantsAndSelf())
    {
        Console.WriteLine(child.Name.LocalName);
    }
    

    DescendantsAndSelf() Returns a collection of elements that contain this element, and all descendant elements of this element, in document order.

提交回复
热议问题