How do I select child elements of any depth using XPath?

后端 未结 4 1474
难免孤独
难免孤独 2021-01-31 01:04

Suppose I have this (simplified):

4条回答
  •  感动是毒
    2021-01-31 01:30

    If you are using the XmlDocument and XmlNode.

    Say:

    XmlNode f = root.SelectSingleNode("//form[@id='myform']");
    

    Use:

    XmlNode s = f.SelectSingleNode(".//input[@type='submit']");
    

    It depends on the tool that you use. But .// will select any child, any depth from a reference node.

提交回复
热议问题