[SoapUI] Common XPath Expressions

Source: Internet
Author: User
Tags xpath soapui

Select a node
expression description
nodename Select all child nodes of this node.
/ from the root node Select.
// from matching Select the current node to select the nodes in the document, regardless of their location.
Select the current node.
: Select the parent node of the current node.
@ select Properties 。

Examples      

Path Expression Results
Bookstore Selects all child nodes of the bookstore element.
/bookstore

Select the root element bookstore.

Note: If the path starts with a forward slash (/), this path always represents the absolute path to an element!

Bookstore/book Selects all book elements that belong to a child element of bookstore.
Book Selects all book child elements, regardless of their position in the document.
Bookstore//book Selects all book elements that belong to descendants of the bookstore element, regardless of where they are located under bookstore.
@lang Select all attributes that are named Lang.
Path Expression Results
/BOOKSTORE/BOOK[1] Selects the first book element that belongs to a bookstore child element.
/bookstore/book[last ()] Select the last book element that belongs to the bookstore child element.
/bookstore/book[last ()-1] Select the second-to-last book element that belongs to the bookstore child element.
/bookstore/book[position () <3] Select the first two book element that belongs to the child element of the bookstore element.
title[@lang] Select all the title elements that have properties named Lang.
title[@lang = ' Eng '] Selects all title elements, and these elements have the lang attribute value of Eng.
/BOOKSTORE/BOOK[PRICE>35.00] Selects all the book elements of the bookstore element, and the value of the price element must be greater than 35.00.
/bookstore/book[price>35.00]/title Selects all the title elements of the book element in the bookstore element, and the value of the price element must be greater than 35.00.
Select Unknown node

XPath wildcard characters can be used to select unknown XML elements.

wildcard characters Description
* Matches any element node.
@* matches any attribute node.
Node () Matches any type of node.

Examples

Path Expression Results
/bookstore/* Selects all child elements of the bookstore element.
//* Selects all elements in the document.
Title[@*] Select all the title elements with attributes.
Select several paths

By using the ' | ' in a path expression operator, you can select a number of paths.

Instance

In the table below, we list some path expressions and the results of these expressions:

Path Expression Results
Book/title | Book/price Selects all the title and price elements of the book element.
Title | Price Selects all the title and price elements in the document.
/bookstore/book/title | Price Selects all the title elements of the book element that belong to the bookstore element, and all the price elements in the document.

Http://www.w3school.com.cn/xpath/xpath_syntax.asp

[SoapUI] Common XPath Expressions

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.