XmlNode.SelectSingleNode returns element outside current?

后端 未结 4 1660
梦谈多话
梦谈多话 2021-02-18 17:01

my problem is like this. Let\'s say i have xml like this


  
    Value1
    

        
4条回答
  •  广开言路
    2021-02-18 17:16

    The "//" is a global look up.

    What you'll need to do is get a list of all children

    XmlNodeList nodes = xmlDoc.SelectNodes("//Child");
    

    loop through that list and do a

    XmlNode node = nodes.SelectSingleNode("element3");
    

    This will return null if it's not there, and will step through every child looking.

提交回复
热议问题