Skip to content

Instantly share code, notes, and snippets.

@Dulani
Created November 14, 2017 21:50
Show Gist options
  • Save Dulani/6e5283cda22842f0d6dd62ce366873e1 to your computer and use it in GitHub Desktop.
Save Dulani/6e5283cda22842f0d6dd62ce366873e1 to your computer and use it in GitHub Desktop.
Some working Xpath expressions.
Xpath
#Starting with what you know you want an xpath expression for, pick it out and then pick its parent out.
//*[Name="Q1"]
//*[Name="Q1"]/parent::*
//Grid[Name="Q1"]/parent::*
#All the text attributes of the name elements of the grid nodes:
//Grid/Name/text()
#All of the grid nodes:
//Grid/*
#The text elements:
//Grid/FormTexts/FormText/Text/text()
#Contents of the relevant Name and Text elements under the grid node.
//Grid/Name/text()|//Grid/FormTexts/FormText/Text/text()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment