XPath & CSS Selector Cheat Sheet, Study notes of Web Programming and Technologies

XPath & CSS Selector. Cheat Sheet. XPath ... CSS Syntax (* = any Tag Name / # (pound) = ID AttributeName /. (dot) = Class AttributeName).

Typology: Study notes

2021/2022

Uploaded on 07/05/2022

lee_95
lee_95 🇦🇺

4.6

(59)

999 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
XPath & CSS Selector
Cheat Sheet
XPath
//TagName[@AttributeName='AttributeValue']
//TagName[@AttributeName='AttributeValue'][@AttributeName='AttributeValue']
//TagName[@AttributeName='AttributeValue' and @AttributeName='AttributeValue']
//TagName[@AttributeName='AttributeValue' or @AttributeName='AttributeValue']
//TagName[@AttributeName='AttributeValue']/TagName[n]/TagName[n]
XPath Partial Pattern Match - //TagName[PartialPatternMatch(@AttributeName,'AttributeValue')]
//TagName[starts-with(@AttributeName,'AttributeValue')]
//TagName[contains(@AttributeName,'AttributeValue')]
XPath Search For Text
//TagName[text()='Value']
XPath Axes
//TagName[text()='Value']//preceding::TagName[n]
//TagName[@AttributeName='AttributeValue']//preceding::TagName[n]
//TagName[text()='Value']//following::TagName[n]
//TagName[@AttributeName='AttributeValue']//following::TagName[n]
CSS
CSS Syntax (* = any TagName / # (pound) = ID AttributeName / . (dot) = Class AttributeName)
TagName#AttributeValue
TagName.AttributeValue
TagName[AttributeName='AttributeValue']
TagName[AttributeName='AttributeValue'][AttributeName='AttributeValue']
CSS nth-child(n) Syntax
TagName[AttributeName='AttributeValue'] TagName TagName:nth-child(n) TagName
CSS Child Select (> = Parent-Child Relationship)
TagName.AttributeValue > TagName.AttributeValue
TagName.AttributeValue > TagName#AttributeValue
pf2

Partial preview of the text

Download XPath & CSS Selector Cheat Sheet and more Study notes Web Programming and Technologies in PDF only on Docsity!

XPath & CSS Selector

Cheat Sheet

XPath

  • //TagName[@AttributeName='AttributeValue']
  • //TagName[@AttributeName='AttributeValue'][@AttributeName='AttributeValue']
  • //TagName[@AttributeName='AttributeValue' and @AttributeName='AttributeValue']
  • //TagName[@AttributeName='AttributeValue' or @AttributeName='AttributeValue']
  • //TagName[@AttributeName='AttributeValue']/TagName[n]/TagName[n] XPath Partial Pattern Match - //TagName[PartialPatternMatch(@AttributeName,'AttributeValue')]
  • //TagName[starts-with(@AttributeName,'AttributeValue')]
  • //TagName[contains(@AttributeName,'AttributeValue')] XPath Search For Text
  • //TagName[text()='Value'] XPath Axes
  • //TagName[text()='Value']//preceding::TagName[n]
  • //TagName[@AttributeName='AttributeValue']//preceding::TagName[n]
  • //TagName[text()='Value']//following::TagName[n]
  • //TagName[@AttributeName='AttributeValue']//following::TagName[n]

CSS

CSS Syntax (* = any TagName / # (pound) = ID AttributeName /. (dot) = Class AttributeName)

  • TagName#AttributeValue
  • TagName.AttributeValue
  • TagName[AttributeName='AttributeValue']
  • TagName[AttributeName='AttributeValue'][AttributeName='AttributeValue'] CSS nth-child(n) Syntax
  • TagName[AttributeName='AttributeValue'] TagName TagName:nth-child(n) TagName CSS Child Select (> = Parent-Child Relationship)
  • TagName.AttributeValue > TagName.AttributeValue
  • TagName.AttributeValue > TagName#AttributeValue

CSS Symbols For Matching Patterns - TagName[AttributeName Symbol='AttributeValue']

  • (^ (caret) = starts-with / * (asterisk) = every element with a specific substring
  • TagName[AttributeName^='AttributeValue']
  • TagName[AttributeName*='AttributeValue']