Basic concepts of XPath (1)

Source: Internet
Author: User
XPath is an important part of XSLT. XPath is used to locate the content of an XML document and access the specified XML Element Through XPath. XPath is a series of rules that specify the access method to the Tree Structure of XML documents. With XPath rules, you can access each node in the tree structure of the XML document according to the specified rules.

XPath describes XML documents as a structure tree. There are seven types of nodes: Element nodes, attribute nodes, and comment nodes. For each node, XPath uses a method to calculate the node value (string-value). XPath fully supports namespace, the node name with the namespace is the extended node name (expanded-name ).

The main syntax structure of XPath is expressions. The expression matches the corresponding access rules by taking values of XPath data objects. Expressions are often used for Attribute matching of XML documents. The values of expressions are usually used for text processing. There are four types of data objects in XPath: node set, Boolean value, string, and number.

(1) node set: A group of nodes matching the XPath syntax according to the given rules. Other data types cannot be converted to node sets. In addition, the "|" operation can only be of the node set type.

(2) Boolean value: There are two values: true or false.

Boolean expressions include:

Or performs the "or" Operation on the left and right operands, or obtains a Boolean value for the left and right operands before the "or" operation. When the first operand is true, the second operand is not taken.

And performs the "and" Operation on the left and right operands, or obtains a Boolean value for the left and right operands before the "and" operation. When the first operand is false, the second operand is not taken.

EqualityExpr includes "= ,! =, <=, <, >=,>. The comparison is performed from left to right.

The expression priority is "or"> "and"> "EqualityExpr", and "= ,! = "Is higher than" <=, <, >=,> ".

(3) string: The data is composed of characters. To ensure that the character encoding is not repeated and there is ambiguity, this problem may occur when the 16-bit Unicode encoding is used.

(4) number: The number type is a floating point in XPath. It can be double-precision data, non-data (), positive infinity, negative infinity, positive and negative 0.

Numeric operators include "+,-, div, and mod"

Nodes are derived, sibling, and ancestor relationships. The node classes include: root node, element node, attribute node, namespace node, command node, comment node, and text node. (Note nodes cannot have extensions. text nodes do not have node extensions)

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.