XPath Expressions
Following are some of the expressions that you can use to select one or more nodes from the XML document above:
/userinfo- Selects the root element./userinfo/username- Selects theusernamenode which is the child ofuserinforoot node.//email- Selects all the nodes in the document which match the name (email) irrespective of where they lie in the document.//username[@admin]- Selects all nodes with the name of "username" which have an attribute; "admin"./userinfo/username[1]- Selects the firstusernamenode that is the child ofuserinfonode./userinfo/username[last()]- Assuminguserinfohad more than oneusernamechild nodes, it will return the lastusernamenode that is the child ofuserinfonode.
相关文章:
浙公网安备 33010602011771号