Common XPath table

Source: Internet
Author: User

CommonXpath

Expression

Description

 

//

ReturnsXMLAll elements in the document that comply with the search criteria are ignored.

 

/

Absolute path

 

News/links/Name

Relative Path

 

./

Indicates the current node

 

../

Parent node

 

*

All elements in the table

 

Or

Or

 

And

And

 

Other Expressions

=,! =,<,>,> =,<=

 

Text ()

Text

 

Node ()

Node

 

Number Last()

Last The function returns a number equal to the context size in the context evaluated from the expression.(Returns the number of nodes.)

 

Number Position()

PositionThe function returns a number equal to the value of the context in the expression.(That is, the current location)

 

Number Count(Node-Set)

CountThe function is returned in the ParameterNode-SetNumber of nodes.

 

Node-Set ID(Object)

 

 

String String(Object?)

StringThe function converts an object to a character according to the following items:

 

String Concat(String,String,String*)

ConcatThe function returns the join of its parameters.

 

Boolean Starts-(String,String)

If the first string parameter starts with the second string parameter,Starts-The function returns true. Otherwise, false is returned.

 

Boolean contains ( string , string )

If the first string parameter contains the second string parameter, contains the function returns true. Otherwise, false is returned.

string substring-before ( string , string )

substring-before the function returns the first string parameter. before the first occurrence of the second parameter, alternatively, if the first string parameter does not contain the second string parameter, an empty string is returned. For example, substring-before (" 2017/04/01 ","/") return 1999 .

string substring-after ( string , string )

substring-after the function returns the first string parameter. after the first occurrence of the second parameter, alternatively, if the first string parameter does not contain the second string parameter, an empty string is returned. For example, substring-after (" 2017/04/01 ","/") return 04/01 , substring-after (" 2017/04/01 "," 19 ") return 99/04/01 .

string substring ( string , Number , Number ?)

substring the function returns the first string parameter from the second parameter (s, a substring with the third parameter as the length. For example, substring ("12345) return "234" . If there is no third parameter, return from the second parameter specified position until the end. For example, substring ("12345", 2) return "2345" .

Number String-length(String? )

String-lengthReturns the number of characters in a string. If the parameter is omitted, a context node is converted to a string by default, that is, the context node's String value.

 

String Normalize-space(String?)

Normalize-spaceNormalization of blank characters returned by the function Parameter string. This normalization is used to clear leading and ending white spaces and replace consecutive white spaces with a blank character. Blank characters andXMLGenerateSThe same is allowed. If the parameter is omitted, a context node is converted to a string by default, that is, the context node's String value.

 

string translate ( string , string , string )

translate the function returns the string of the first parameter, the characters that appear in the second parameter are replaced by the characters at the corresponding position in the third parameter. For example, translate ("bar", "ABC", "ABC ") return string bar . If the character in the second parameter does not have a character at the corresponding position of the third parameter (because the character string in the second parameter is longer than the character string of the third parameter), then, the character in the first parameter will be removed. For example, translate ("-- AAA --", "ABC-", "ABC ") return "AAA" . If the character in the second parameter appears more than once, the first occurrence determines the character to be replaced. If the string in the third parameter is longer than the string in the second parameter, extra characters are ignored.

Boolean Not(Boolean)

If the parameter is trueNotThe function returns true, otherwise false.

 

Boolean True()

TrueFunction returns true.

 

Boolean False()

The falseThe function returns false.

 

Number Number(Object?)

NumberFunction parameters are converted to numbers according to the following items:

 

Number Sum(Node-Set)

For each node in the parameter node set,SumThe function returns the sum after the string value of the node is converted to a number.

 

Number Floor(Number)

FloorReturns the maximum number of integers not greater than the value of the parameter. (Closest to positive infinity)

 

Number Ceiling(Number)

CeilingReturns the minimum number of integers not less than the value of the parameter. (Closest to negative infinity

 

Number Round(Number)

RoundReturns the integer closest to the parameter.

 

//*

Get all nodes

 

../*

Obtain all the nodes of the parent node of the current node.

 

// Links

Obtain allLinksNode

 

// Links [name ="Netease"]

Obtain subnodesNameIs"Netease"AllLinksNode

 

// Links [@ ID =" 1" ]

Get attributesId = 1AllLinksNode

 

// * [Name ="Sina"]

Obtain subnodesNameIs"Sina"All nodes

 

// * [@ ID =" 1" ]

Get attributesId = 1All nodes

 

// * [@ ID]

Obtain the ownerIDAll vertices

 

// * [Name]

Obtain the child nodeNameAll nodes

 

// Links [Serial number]

ReturnsNItemsLinksNode No.

 

// Links [1 or 2]

ReturnsNItemsLinksThe first and second nodes in the node

 

// * [Name ="Netease"And @ ID =" 1" ]

Get all subverticesNameIs"Netease"And its own ownerId = "1"Node

 

// Text ()

Select all body nodes(That is, leaf nodes)

 

// Links [position () = last ()]

ReturnsNItemsLinksThe last node in the node.

Equivalent// Links [last ()]

 

// * [Contains (name ,"New")]

Obtain subnodesNameContains"New"All nodes

 

// Links [1]

ReturnsNItemsLinksThe first node in the node

 

// Links [1]/name [1]

Obtain the firstLinksThe firstNameNode

 

// Links // name

Get allLinksAllNameNode

 

// * [@ ID> 1]

Get attributesId> 1All nodes

 

// * [Number (@ ID) + 1> 1]

Obtain ownerIDValue addition1> 1All nodes

 

// * [Number (text ()> 1]

The obtained text node value is greater1All nodes

 

// * [(Number (text () Mode 2) = 1]

Obtain all nodes whose text value is base

 

 

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.