Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Advanced XPath

Advanced XPath

Avatar for benbayard

benbayard

August 21, 2014

More Decks by benbayard

Other Decks in Programming

Transcript

  1. This allows us to move around the tree in a

    given context. If we know our current node, we can utilize that to tell use information about parents, siblings, and even children.
  2. ancestor::* Look up the tree from the starting node at

    the parents, grandparents, etc. and check them against the following Xpath.
  3. self::* Selects the current node. This is useful for selecting

    the current node only if a given set of criteria are true.
  4. following-sibling::* preceding-sibling::* Indicates all the nodes that have the same

    parent as the context node and appear after/ before the context node in the source document.
  5. descendant-or-self::* Indicates the context node and all of its descendants.

    Mostly useful for applying transformations in bulk.
  6. XPath has a number of functions that can be applied

    to a selector to ensure you are selecting the correct node.
  7. not(input) Selects if the input is not true count(selector) Counts

    the number of the given selector last() True if the node is the last node in the selector contains(attribute, string) True if the attribute has the string in it.