Reading multiple child nodes of xml file

后端 未结 3 627
挽巷
挽巷 2020-12-17 15:33

I have created an Xml file with example contents as follows:



  

        
3条回答
  •  情书的邮戳
    2020-12-17 16:23

    Since the XmlDocument.SelectNodes method actually accepts an XPath expression, you're free to go like this:

    XmlNodeList xnl = doc.SelectNodes("/Periods/PeriodGroup[@name='" + PG + "']/Period");
    foreach (XmlNode node in xnl) {
        // Every node here is a  child of the relevant .
    }
    

    You can learn more on XPath at w3schools.

提交回复
热议问题