how to remove xmlnode within a foreach loop?

前端 未结 5 1850
北荒
北荒 2021-01-07 04:04

At the following code i use foreach loop to check each node in nodelist and remove some of them. after i remove one node the foreach loop throw the following error: \"The el

5条回答
  •  臣服心动
    2021-01-07 04:47

    I found an alterative: Convert xmlnodelist to list<>

    XmlNodeList has a method Cast and can be used as follows:

    var listOfNodes = new List(xmlNodeList.Cast());
    

提交回复
热议问题