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 the username node which is the child of userinfo root 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 first username node that is the child of userinfo node.
  • /userinfo/username[last()] - Assuming userinfo had more than one username child nodes, it will return the last username node that is the child of userinfo node.

 

相关文章:

  • Introduction to XML
  • Reading XML Files with ASP.NET
  • Introduction to XPath for ASP.NET Developers
  • Creating new XML Document in ASP.NET Programmatically
  • Introduction to DTD (Document Type Definition)
  • Validating an XML Document using DTD in ASP.NET
  • posted on 2010-05-21 15:27  佐伊凡  阅读(119)  评论(0编辑  收藏  举报