Tutorial for beginners of XPath: XPath nodes

Source: Internet
Author: User
In XPath, there are seven types of nodes: elements, attributes, text, namespaces, processing commands, comments, and document nodes (or become root nodes ). In XPath, Node has seven types of nodes: elements, attributes, and text.

In XPath, there are seven types of nodes: elements, attributes, text, namespaces, processing commands, comments, and document nodes (or become root nodes ).

XPath term Node)

There are seven types of nodes in XPath: elements, attributes, text, namespaces, processing commands, comments, and document (root) nodes. XML documents are viewed as node trees. The root of a tree is called a document node or a root node.

See the following XML document:

 
 
    
   Harry Potter  J K. Rowling   
   
    2005
     
   
    29.99
   
  
 

Node example in the XML document above:

 
  
(Document Node) j k. Rowling(Element node) lang = 'en' (attribute node)
 
Base value (or Atomic value, Atomic value)

The base value is a node with no parent or child.

Example of basic value:

J K. Rowling'en'
Item)

A project is a base value or node.

Parent node)

Each element and attribute has a parent.

In the following example, the book element is the parent of the title, author, year, and price elements:

   
  Harry Potter  J K. Rowling  
  
   2005
    
  
   29.99
  
 
Child)

There can be zero, one, or more sub-nodes.

In the following example, the title, author, year, and price elements are child of the book element:

   
  Harry Potter  J K. Rowling  
  
   2005
    
  
   29.99
  
 
Sibling)

Having the same parent node

In the following example, the title, author, year, and price elements are all siblings:

   
  Harry Potter  J K. Rowling  
  
   2005
    
  
   29.99
  
 
Advanced (Ancestor)

The parent and parent of a node.

In the following example, the first generation of the title element is the book element and the bookstore element:

 
    
   Harry Potter  J K. Rowling  
   
    2005
     
   
    29.99
   
  
 
Descendant (Descendant)

The child of a node, the child of the child, and so on.

In the following example, the future generations of bookstore are book, title, author, year, and price:

 
    
   Harry Potter  J K. Rowling  
   
    2005
     
   
    29.99
   
  
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.