This shows you the differences between two versions of the page.
identificacion_de_objetos_por_xpath [2020/10/22 11:55] montse |
identificacion_de_objetos_por_xpath [2020/10/22 12:33] (current) montse |
||
---|---|---|---|
Line 11: | Line 11: | ||
^ XPath Expression ^ Description ^ Expression example ^ Example meaning ^ | ^ XPath Expression ^ Description ^ Expression example ^ Example meaning ^ | ||
- | |/|Selects from the root node. |(...)/b/a |Element "//a//" child of "//b//", child of "//(...)//"| | + | |/|Selects from the root node. |(...)/b/a |Element "//a//" child of "//b//", child of "//(...)//".| |
|/ /|Selects any nodes from the current node that match the selection no matter where they are. |b / / a(...)|All the "//a(...)//" elements child of "//b//".| | |/ /|Selects any nodes from the current node that match the selection no matter where they are. |b / / a(...)|All the "//a(...)//" elements child of "//b//".| | ||
- | |* |Matches any element node (wildcard). |b / * / a |Any "//a//" element whose grandparent is "//b//"| | + | |* |Matches any element node (wildcard). |b / * / a |Any "//a//" element whose grandparent is "//b//".| |
- | |. |Selects the current node. |./ /de |Any "//de//" element that is one or more levels inside the current node| | + | |. |Selects the current node. |./ /de |Any "//de//" element that is one or more levels inside the current node.| |
- | |.. |Selects the parent of the current node. |abc[../mg] |Any "//abc//" element that has a "//mg//" sibling| | + | |.. |Selects the parent of the current node. |abc[../mg] |Any "//abc//" element that has a "//mg//" sibling.| |
- | |@ |Selects attributes. |a[@bcd] |"//a//" element with a "//bcd//" attribute| | + | |@ |Selects attributes. |a[@bcd] |"//a//" element with a "//bcd//" attribute.| |
- | |@ = |Selects attributes with a value. |a[@bcd="hola"] |"//a//" element with a "//bcd//" attribute equal to hola| | + | |@ = |Selects attributes with a value. |a[@bcd="hola"] |"//a//" element with a "//bcd//" attribute equal to hola.| |
- | |@* |Matches any attribute node. |a[@*="hola"] |"//a//" element with any attribute equal to //hola//| | + | |@* |Matches any attribute node. |a[@*="hola"] |"//a//" element with any attribute equal to //hola//.| |
- | |last() |Matches the last element. |b / a[last()] |The last "//a//" element child of "//b//"| | + | |last() |Matches the last element. |b / a[last()] |The last "//a//" element child of "//b//".| |
- | |[] |Element that contains something. |c[hello] / b[@a] |"//b//" element that contains an "//a//" attribute, child of a "//c//" that contains a hello element| | + | |[] |Element that contains something. |c[hello] / b[@a] |"//b//" element that contains an "//a//" attribute, child of a "//c//" that contains a hello element.| |
- | |[][] |Element that contains two things (or more, if more brackets are added). |a[@b][@c] |"//a//" element with **both** a "//b//" attribute and a "//c//" attribute| | + | |[][] |Element that contains two things (or more, if more brackets are added). |a[@b][@c] |"//a//" element with **both** a "//b//" attribute and a "//c//" attribute.| |
- | |[n] |The n-th element. |b/a[3] |The 3rd "//a//" element child of "//b//"| | + | |[n] |The n-th element. |b/a[3] |The 3rd "//a//" element child of "//b//".| |
- | |!= |Not equal. |a[@bcd!="hola"] |"//a//" element with a "//bcd//" attribute NOT equal to //hola//| | + | |!= |Not equal. |a[@bcd!="hola"] |"//a//" element with a "//bcd//" attribute NOT equal to //hola//.| |
- | |last() |Last element. |b/a[last()] |the last "//a//" that is child of a "//b//"| | + | |last() |Last element. |b/a[last()] |the last "//a//" that is child of a "//b//".| |
- | |() |Groups operations for establishing the priorities. |(de/mg)[3] |the third entire set "//de/mg//"| | + | |() |Groups operations for establishing the priorities. |(de/mg)[3] |the third entire set "//de/mg//".| |
- | |and |Logical AND as usual. |a[b and c] |"//a//" element containing **both** "//b//" and "//c//"| | + | |and |Logical AND as usual. |a[b and c] |"//a//" element containing **both** "//b//" and "//c//".| |
- | |or |Logical OR as usual. |de[@mg or @dus] |"//de//" element containing a "//mg//" attribute or a "//dus//" attribute| | + | |or |Logical OR as usual. |de[@mg or @dus] |"//de//" element containing a "//mg//" attribute or a "//dus//" attribute.| |
- | |contains() |Matches all the elements that (partially) contains what is inside the brackets. |de[contains(.,'click here')] |"//de//" elements with a text containing "//click here//"| | + | |contains() |Matches all the elements that (partially) contains what is inside the brackets. |de[contains(.,'click here')] |"//de//" elements with a text containing "//click here//".| |
- | |starts-with() |Matches all the elements that start with what is inside the brackets. |de[starts-with(@id,'id-name')] |"//de//"elements whose id starts with "//id-name(...)//"| | + | |starts-with() |Matches all the elements that start with what is inside the brackets. |de[starts-with(@id,'id-name')] |"//de//" elements whose id starts with "//id-name(...)//".| |
- | |[ .=''] |Matches the elements with a string. |de[.='string 1 of 6'] |"//de//" elements with the string "//string 1 of 6//"| | + | |[ .=''] |Matches the elements with a string. |de[.='string 1 of 6'] |"//de//" elements with the string "//string 1 of 6//".| |
- | |normalize-space() |Matches the elements with a string, ignoring leading or trailing blank spaces. |de[normalize-space()='mg'] |"//de//" elements with the string "//mg//" or "// mg//" or "//mg //" or "// mg //"| | + | |normalize-space() |Matches the elements with a string, ignoring leading or trailing blank spaces. |de[normalize-space()='mg'] |"//de//" elements with the string "//mg//" or "// mg//" or "//mg //" or "// mg //".| |
- | |text() |Selects the elements with a specific text within. |de[text()="mg"] |"//de//" elements with the string "//mg//" in the text field| | + | |text() |Selects the elements with a specific text within. |de[text()="mg"] |"//de//" elements with the string "//mg//" in the text field.| |
- | |[ / @ ] |Selects the elements that have specific children.| / / de[mg/@attr1='nrw']|"//de//" elements which have a "//mg//" child with an attribute "//attr1//" equal to "//nrw//"| | + | |[ / @ ] |Selects the elements that have specific children.| / / de[mg/@attr1='nrw']|"//de//" elements which have a "//mg//" child with an attribute "//attr1//" equal to "//nrw//".| |
\\ | \\ | ||
===== How to Obtain Xpath in a XML document ===== | ===== How to Obtain Xpath in a XML document ===== |