-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxpath.txt
105 lines (71 loc) · 2.93 KB
/
xpath.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
* From http://www.w3schools.com/xpath/xpath_syntax.asp
* Common predicates
* /bookstore/book[1]
$ Selects the first book element that is the child of the bookstore element.
* /bookstore/book[last()]
$ Selects the last book element that is the child of the bookstore element
* /bookstore/book[last()-1]
$ Selects the last but one book element that is the child of the bookstore element
* /bookstore/book[position()<3]
$ Selects the first two book elements that are children of the bookstore element
* //title[@lang]
$ Selects all the title elements that have an attribute named lang
* //title[@lang='eng']
$ Selects all the title elements that have an attribute named lang with a value of 'eng'
* /bookstore/book[price>35.00]
$ Selects all the book elements of the bookstore element that have a price element with a value greater than 35.00
* /bookstore/book[price>35.00]/title
$ Selects all the title elements of the book elements of the bookstore element that have a price element with a value greater than 35.00
* employee[@secretary and @assistant]
$ selects all the employee children of the context node that have both a secretary attribute and an assistant attribute
* chapter[title]
$ selects the chapter children of the context node that have one or more title children
* Common path expressions
* nodename
$ Selects all nodes with the name "nodename"
* /
$ Selects from the root node
* //
$ Selects nodes in the document from the current node that match the selection no matter where they are
* .
$ Selects the current node
* ..
$ Selects the parent of the current node
* @
$ Selects attributes
* Common path expressions and their results
* bookstore
$ Selects all nodes with the name "bookstore"
* /bookstore
$ Selects the root element bookstore
$ Note: If the path starts with a slash ( / ) it always represents an absolute path to an element!
* bookstore/book
$ Selects all book elements that are children of bookstore
* //book
$ Selects all book elements no matter where they are in the document
* bookstore//book
$ Selects all book elements that are descendant of the bookstore element, no matter where they are under the bookstore element
* //@lang
$ Selects all attributes that are named lang
* Select unknown nodes
* *
$ Matches any element node
* @*
$ Matches any attribute node
* node()
$ Matches any node of any kind
* /bookstore/*
$ Selects all the child nodes of the bookstore element
* //*
$ Selects all elements in the document
* //title[@*]
$ Selects all title elements which have any attribute
* Select several paths
* //book/title | //book/price
$ Selects all the title AND price elements of all book elements
* //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 of the bookstore element AND all the price elements in the document
* Get text value of attribute node
$ string(/book/@src)