In the selectnodes (XPath, namespace) Method
Whether xmldoc. selectnodes (XPath, namespace) // assume that xmldoc is the root node,Queries under the entire document
Or xmldoc. childnodes [I]. selectnodes (XPath, namespace )//Query under a node
The results of the two queries are the same: All documents that comply with the XPath syntax conditions are checked out.
In fact, all we need is the result that meets the XPath syntax under a node.
After a complete query and research solution...
Xmldoc. childnodes [I]. Clone (). selectnodes (XPath, namespace) can be used to solve the problem.
After cloning a node, You can query it from the cloned node to find the desired result.
But another problem arises. Since the query result is cloned, the original xmldoc will not change even if the result node is changed.
The temporary Method for associating changes is to traverse xmldoc. childnodes [I], locate the nodes that meet the conditions, and replace the result nodes.
Summary:
Now that we have to traverse the replacement results, the previous clone node query seems a little redundant. The first direct traversal is not enough.
Conclusion:
Is the node. selectnodes method under a certain node significant?
Selectnodes can only be used in the entire XML document!
Edit the final answer:
I encountered it again today. Record it. The correct method is:
Subnode. selectnodes ("Descendant: node name", namespace)