IT - TOOLS
Handy tools for developers
Barcode Reader
Barcode generator
GTIN Validator
QR Code decoder
QR Code generator
QR Contact Info generator
WiFi QR Code generator
Bash Cheatsheet
CSS Selectors Cheatsheet
Common Regex Cheatsheet
Docker Cheatsheet
Docker Compose cheatsheet
Docker SWARM cheatsheet
Dockerfile cheatsheet
Git Semantic Commit Cheatsheet
Git cheatsheet
JSONPath Syntax Cheatsheet
Jq Cheatsheet
K8s Cheatsheet
Markdown Cheat Sheet
Nano CheatSheet
Nginx Cheatsheet
Regex cheatsheet
Sed cheatsheet
VIM Cheatsheet
XPath Syntax Cheatsheet
Base64 Hex array encoder/decoder
Base64 file converter
Base64 string encoder/decoder
Csv to Data
Data Storage Unit converter
Email normalizer
Energy Consumption and Expense Computer
Env Variables Format Converter
Excel to data
Integer base converter
Many Units Converter
Properties converter
Roman numeral converter
Text to UTF-8 binary
Text to Unicode
Torrent to Magnet
ULID generator
Unicode Characters to Java Entities Converter
AGE Cryptography
Ansible vault crypt decrypt
Bcrypt
CRC calculator
CSR Generator
Certificate/Key parser
ECDSA key pair generator
Ed25519 key pair generator
Encrypt / decrypt text
File Hasher
Hash text
Hmac generator
JWT Generator
JWT parser
Niceware Bytes to Passphrase
PGP encryption
PGP keygen
Paseto/PASERK Local
Paseto/PASERK Public/Private
RSA encryption
RSA key pair generator
RSA/DSA/ECDSA Signer and Verifier
SSL Certificate converter
X509 certificate generator
BMI Calculator
Credit Card Checker
Credit Card Number Generator
Currency Converter
IBAN validator and parser
IES Lighting Guidelines
ISBN Validator and Parser
ISO 3166 Country Codes Searcher
Luhn Validator
Phone parser and formatter
RMB Uppercase Converter
SLA calculator
Software licence compatibility
Unicode Search
VAT Numbers Validator
Chronometer
Countdown
Cron/Weekday Alarm
Date+Durations Calculator
Date-time converter
Days Calculator
Duration Calculator
ETA calculator
ICAL File Parser
ICAL Generator
TTL calculator
Time Alarm
Timezone Converter
Week Numbers Converter
Which Day?
iCal Merger
dBm mW Converter
ANSI Escape Tester
API Tester
Cli command editor
Code/Scripts Highlighter
Curl Converter
Data Faker
Database Connection String Builder
Django Secret Generator
Favicon Generator
HEX File Converter
Javascript Prettifier
Javascript Unobfuscator/Unpacker
Json to Protobuf
Json to SQL INSERT
Json to Typescript
Mailto Generator
Open graph meta generator
Pomodoro Timer
Quote Converter
SQL Minifier
SQL Parameters Generator
SQL prettify and format
Stacktrace prettier
String Escaper
Swagger UI tester
Docker Compose Format Converter
Docker Compose Validator
Docker Compose to Docker run converter
Docker Compose to Quadlets
Docker compose to kubernetes
Docker inspect to Docker run
Docker run to Docker compose converter
Docker run to Quadlets
Docker run to kubernetes
Traefik Docker Compose Maker
ActiveDirectory LDAP properties searcher
Bounce Email Parser
Cookies Parser
DMARC Report Analyzer
Email Parser
File Type Detector
Floating point number converter
GZip/Deflate converter
Hex Encoder/Decoder
Keycode info
MIME Encoding Converter
Middle-Endian Converter
MongoDB ObjectId Converter
Outlook MSG Parser
Outlook Safelink decoder
Parquet files Reader
Resistor Calculator
SMART Raw Converter
Sensitive data masker
Sharepoint Share Url Decoder
Snowflake ID extractor
TCPDump Generator
Text Charset Detector/Decoder
URL parser
Card Picker
Coin Flipper
Dice Roller
Fortune wheel
BIP39 passphrase generator
Diceware Password Generator
NanoIDs generator
Numeronym generator
OTP code generator
Passphrase Generator
Pin Code Generator
Random numbers generator
Token generator
UUID converter
UUIDs generator
Camera recorder
HEIC Converter
ICO/PNG converter
Image Color Inverter
Image Comparer
Image EXIF/Metadata/GPS/JPEG Quality reader
Image Formats Converter
Image resizer
Image to SVG (potrace)
OCRize image and PDF
Remove EXIF
Watermarker
CSV to JSON
JS to JSON converter
JSON Editor
JSON Flattener/Unflattener
JSON Linter
JSON Merger
JSON diff
JSON minify
JSON prettify and format
JSON sort master
JSON to C#
JSON to CSV
JSON to Data
JSON to Go
JSON to JS converter
JSON to Java Entity
JSON to TOML
JSON to TS
JSON to XML
JSON to YAML converter
JSON to object
Jq/JSONPath Tester
Json Escaper/Unescaper
Json Query
Json Size Analyzer
Json string converter
Json to PHP Code
Json to PHP-Array
Json to Python
Json to SQL DDL
Json to Schema
PHP-Array to JSON
Html to markdown
Markdown Editor
Markdown Table Prettifier
Markdown to DOCX
Markdown to HTML
Markdown toc generator
Paste as Markdown
Math Formats Converter
Math OCR
Math evaluator
Aspect Ratio Calculator
Benchmark builder
Geo distance calculator
Percentage calculator
Apache LogRotate Generator
BIMI DNS Generator
Basic auth generator
Chmod calculator
Crontab generator
Curl Command Generator
DKIM DNS Generator
DMARC DNS Generator
DNS Queries
DNSBL Checker
Data Transfer Rate Calculator
FStab Generator
FW command line generator
HAR Sanitizer
HDD calculator
HTAccess generator
Htpasswd/htaccess generator
IP Geo Location
IP Subnets Exclude Calculator
IPv4 address converter
IPv4 range expander
IPv4 subnet calculator
IPv4-6/IPRange/CIDR in IPRange/CIDR/IPMask
IPv4/6 Range to CIDR(s) Calculator
IPv6 ULA generator
Integers to IPv4/IPv6
Iptables Generator
Ipv4/6 CIDR to IP Range Calculator
Ipv6 address converter
Ipv6 subnet calculator
MAC Address Converter
MAC address generator
MAC address lookup
Microphone Tester
Multi link downloader
My IP Address
Nginx formatter
Option43 generator
Password strength analyser
Port Numbers
Punycode Converter
RAID Calculator
RAID Reliability Calculator
Random port generator
Rsync Generator
SIP Authorization
SPF DNS generator
WPA PSK generator
Websocket tester
Whois Checker
Wireguard Config Generator
X-VR-SpamCause Decoder
ZPOOL RAID calculator
ZPool Cheatsheet
Zxcvbn Password Strength
PDF Text Extractor
PDF signature checker
Pdf Concatener
Pdf Decrypt and Unlock
Pdf Encrypt
Pdf Linearize/FastWeb
Pdf Page Extractor
Angle Units Converter
Area Units Converter
Energy Units Converter
Force Units Converter
Illuminance Converter
Length Units Converter
Mass Units Converter
Power Converter
Pressure Units Converter
Temperature converter
Volume Units Converter
TOML Linter
TOML to JSON
TOML to YAML
AI Prompt Splitter
ASCII Art Text Generator
Case converter
Citation Generator
Distinct Words
Duplicate Lines Finder
Emoji picker
Extract text from HTML
Folder Structure Diagram
Font Compare
GPT Token Encoder/Decoder
GPT Token Estimator
Image to ASCII Art
Keyboard Layout Converter
Levenshtein Calculator
List converter
Lists Comparer
Lorem ipsum generator
Mermaid exporter
Morse Code Converter
Pack files for AI
Regex Tester
Rune converter
Sed Command generator
Smart Text Replacer and Linebreaker
Social Link Sharer
String obfuscator
Text Translator
Text diff
Text statistics
Text to NATO alphabet
Text to Unicode Names
Unicode Formatter
Unicode to GSM-7
CSS XPath Converter
Color Contrast Checker
Color Wheel
Color converter
Css prettifier
Device information
Encode/decode url formatted strings
Escape HTML entities
HTML Minifier
HTML WYSIWYG editor
HTTP status codes
Html Prettifier
Html cleaner
Image to CSS
MIME types
REM Pixel converter
SVG placeholder generator
Slugify string
UTM Url Generator
Url Cleaner
Url Fanger
Url Text Search Fragment Maker
User-agent parser
XML Linter
XML formatter
XML to JSON
XPath Tester
XSLT tester
YAML Flattener/Unflattener
YAML Merger
YAML prettify and format
YAML to JSON converter
YAML to TOML
IT-Tools v2025.10.19
© 2025 Khuong Dev
English
عربي
Dansk
Deutsch
English
Español
Français
Gaeilge
Italiano
한국인
Nederlands
Norwegian
Polski
Português
Русский
Türkçe
Українська
Tiếng Việt
中文
Buy me a coffee

XPath Syntax Cheatsheet

XPath Syntax Cheatsheet

Credit to the original author: https://gist.github.com/jmaccabee/550a0b9fcfdc7e6b170cd34c6ec7bc56

0. XPath Examples.

More: http://xpath.alephzarro.com/content/cheatsheet.html

XPathDescription
//hr[@class="edge" and position()=1]every first hr of ‘edge’ class
//table[count(tr)=1 and count(tr/td)=2]all tables with 1 row and 2 cols
//div/form/parent::*all divs that have form
./div/ba relative path
//table[parent::div[@class="pad"] and not(@id)]//aany anchor in a table without id, contained in a div of “pad” class
/html/body/div/*[preceding-sibling::h4]give me whatever after h4
//tr/td[font[@class="head" and text()="TRACK"]]all td that has font of a “head” class and text “TRACK”
./table/tr[last()]the last row of a table
//rdf:Seq/rdf:li/em:idusing namespaces
//a/@hrefhrefs of all anchors
//*[count(*)=3]all nodes with 3 children
//var|//acronymall vars and acronyms

1. General.

XPathDescription
/htmlwhole web page (css: html)
/html/bodywhole web page body (css: body)
//text()all text nodes of web page
/html/body/.../.../.../Eelement <E> by absolute reference (css: body > … > … > … > E)

2. Tag.

XPathDescription
//Eelement <E> by relative reference (css: E)
(//E)[2]second <E> element anywhere on page
//imgimage element (css: img)
//E[@A]element <E> with attribute A (css: E[A])
//E[@A="t"]element <E> with attribute A containing text ‘t’ exactly (css: E[A=‘t’])
//E[contains(@A,"t")]element <E> with attribute A containing text ‘t’ (css: E[A*=‘t’])
//E[starts-with(@A, "t")]element <E> whose attribute A begins with ‘t’ (css: E[A^=‘t’])
//E[ends-with(@A, "t")]element <E> whose attribute A ends with ‘t’ (css: E[A$=‘t’])
//E[contains(concat(" ", @A, " "), " w ")element <E> with attribute A containing word ‘w’ (css: E[A~=‘w’])
//E[matches(@A, "r")]element <E> with attribute A matching regex ‘r’
//E1[@id=I1] | //E2[@id=I2]element <E1> with id I1 or element <E2> with id I2 (css: E1#I1, E2#I2)
//E1[@id=I1 or @id=I2]element <E1> with id I1 or id I2 (css: E1#I1, E1#I2)

3. Attribute.

XPathDescription
//E/@Aattribute A of element <E> (css: E@A)
//*/@Aattribute A of any element (css: *@A)
//E[@A2="t"]/@A1attribute A1 of element <E> where attribute A2 is ‘t’ exactly (css: E[A2=‘t’]@A1)
//E[contains(@A,"t")]/@Aattribute A of element <E> where A contains ‘t’ (css: E[A*=‘t’]@A)

4. ID and Name.

XPathDescription
//*[@id="I"]element with id I (css: #I)
//E[@id="I"]element <E> with id I (css: E#I)
//*[@name="N"]element with name (css: [name=‘N’])
//E[@name="N"]element <E> with name (css: E[name=‘N’])
//*[@id="X" or @name="X"]element with id X or, failing that, a name X
//*[@name="N"][v+1]element with name N & specified 0-based index ‘v’ (css: [name=‘N’]:nth-child(v+1))
//*[@name="N"][@value="v"]element with name N & specified value ‘v’ (css: *[name=‘N’][value='v’])

5. Lang and Class.

XPathDescription
//E[@lang="L" or starts-with(@lang, concat("L", "-"))]element <E> is explicitly in language L or subcode (css: E[lang|=L])
//*[contains(concat(" ", @class, " "), " C ")]element with a class C (css: .C)
//E[contains(concat(" ", @class, " "), " C ")]element <E> with a class C (css: E.C)

6. Text and Link.

XPathDescription
//*[.="t"]element containing text ‘t’ exactly
//E[contains(text(), "t")]element <E> containing text ‘t’ (css: E:contains(‘t’))
//alink element (css: a)
//a[.="t"]element <a> containing text ‘t’ exactly
//a[contains(text(), "t")]element <a> containing text ‘t’ (css: a:contains(‘t’))
//a[@href="url"]<a> with target link ‘url’ (css: a[href=‘url’])
//a[.="t"]/@hreflink URL labeled with text ‘t’ exactly

7. Parent and Child.

XPathDescription
//E/*[1]first child of element <E> (css: E > *:first-child)
//E[1]first <E> child (css: E:first-of-type)
//E/*[last()]last child of element E (css: E *:last-child)
//E[last()]last <E> child (css: E:last-of-type)
//E[2]second <E> child (css: E:nth-of-type(2))
//*[2][name()="E"]second child that is an <E> element (css: E:nth-child(2))
//E[last()-1]second-to-last <E> child (css: E:nth-last-of-type(2))
//*[last()-1][name()="E"]second-to-last child that is an <E> element (css: E:nth-last-child(2))
//E1/[E2 and not( *[not(self::E2)])]element <E1> with only <E2> children
//E/..parent of element <E>
//*[@id="I"]/.../.../.../Edescendant <E> of element with id I using specific path (css: #I > … > … > … > E)
//*[@id="I"]//Edescendant <E> of element with id I using unspecified path (css: #I E)
//E[count(*)=0]element <E> with no children (E:empty)
//E[count(*)=1]element <E> with an only child
//E[count(preceding-sibling::*)+count(following-sibling::*)=0]element <E> that is an only child (css: E:only-child)
//E[count(../E) = 1]element <E> with no <E> siblings (css: E:only-of-type)
//E[position() mod N = M + 1]every Nth element starting with the (M+1)th (css: E:nth-child(Nn+M))

8. Sibling.

XPathDescription
//E2/following-sibling::E1element <E1> following some sibling <E2> (css: E2 ~ E1)
//E2/following-sibling::*[1][name()="E1"]element <E1> immediately following sibling <E2> (css: E2 + E1)
//E2/following-sibling::*[2][name()="E1"]element <E1> following sibling <E2> with one intermediary (css: E2 + * + E1)
//E/following-sibling::*sibling element immediately following <E> (css: E + *)
//E2/preceding-sibling::E1element <E1> preceding some sibling <E2>
//E2/preceding-sibling::*[1][name()="E1"]element <E1> immediately preceding sibling <E2>
//E2/preceding-sibling::*[2][name()="E1"]element <E1> preceding sibling <E2> with one intermediary
//E/preceding-sibling::*[1]sibling element immediately preceding <E>

9. Table Cell.

XPathDescription
//*[@id="TestTable"]//tr[3]//td[2]cell by row and column (e.g. 3rd row, 2nd column) (css: #TestTable tr:nth-child(3) td:nth-child(2))
//td[preceding-sibling::td="t"]cell immediately following cell containing ‘t’ exactly
td[preceding-sibling::td[contains(.,"t")]]cell immediately following cell containing ‘t’ (css: td:contains(‘t’) ~ td)

10. Dynamic.

XPathDescription
//E[@disabled]user interface element <E> that is disabled (css: E:disabled)
//*[not(@disabled)]user interface element that is enabled (css: E:enabled)
//*[@checked]checkbox (or radio button) that is checked (css: *:checked)

11. XPath Functions.

https://developer.mozilla.org/en-US/docs/Web/XPath/Functions

11.1. Conversion.

XPathDescription
boolean(expression)evaluates an expression and returns true or false.
string([object])converts the given argument to a string.
number([object])converts an object to a number and returns the number.

11.2. Math.

XPathDescription
ceiling(number)evaluates a decimal number and returns the smallest integer greater than or equal to the decimal number.
floor(number)evaluates a decimal number and returns the largest integer less than or equal to the decimal number.
round(decimal)returns a number that is the nearest integer to the given number.
sum(node-set)returns a number that is the sum of the numeric values of each node in a given node-set.

11.3. Logic.

XPathDescription
true()returns a boolean value of true.
false()returns boolean false.
not(expression)evaluates a boolean expression and returns the opposite value.

11.4. Node.

XPathDescription
lang(string)determines whether the context node matches the given language and returns boolean true or false.
name([node-set])returns a string representing the QName of the first node in a given node-set.
namespace-uri([node-set])returns a string representing the namespace URI of the first node in a given node-set.

11.5. Context.

XPathDescription
count(node-set)counts the number of nodes in a node-set and returns an integer.
function-available(name)determines if a given function is available and returns boolean true or false.
last()returns a number equal to the context size from the expression evaluation context.
position()returns a number equal to the context position from the expression evaluation context.

11.6. String.

XPathDescription
contains(haystack-string, needle-string)determines whether the first argument string contains the second argument string and returns boolean true or false.
concat(string1, string2 [stringn]*)concatenates two or more strings and returns the resulting string.
normalize-space(string)strips leading and trailing white-space from a string, replaces sequences of whitespace characters by a single space, and returns the resulting string.
starts-with(haystack, needle)checks whether the first string starts with the second string and returns true or false.
string-length([string])returns a number equal to the number of characters in a given string.
substring(string, start [length])returns a part of a given string.
substring-after(haystack, needle)returns a string that is the rest of a given string after a given substring.
substring-before(haystack, needle)returns a string that is the rest of a given string before a given substring.
translate(string, abc, XYZ)evaluates a string and a set of characters to translate and returns the translated string.

12. XPath Axes.

XPathDescription
ancestorindicates all the ancestors of the context node beginning with the parent node and traveling through to the root node.
ancestor-or-selfindicates the context node and all of its ancestors, including the root node.
attribute (@)indicates the attributes of the context node. Only elements have attributes. This axis can be abbreviated with the at sign (@).
child (/)indicates the children of the context node. If an XPath expression does not specify an axis, this is understood by default. Since only the root node or element nodes have children, any other use will select nothing.
descendant (//)indicates all of the children of the context node, and all of their children, and so forth. Attribute and namespace nodes are not included - the parent of an attribute node is an element node, but attribute nodes are not the children of their parents.
descendant-or-selfindicates the context node and all of its descendants. Attribute and namespace nodes are not included - the parent of an attribute node is an element node, but attribute nodes are not the children of their parents.
followingindicates all the nodes that appear after the context node, except any descendant, attribute, and namespace nodes.
following-siblingindicates all the nodes that have the same parent as the context node and appear after the context node in the source document.
parent(..)indicates the single node that is the parent of the context node. It can be abbreviated as two periods (…).
precedingindicates all the nodes that precede the context node in the document except any ancestor, attribute and namespace nodes.
preceding-siblingindicates all the nodes that have the same parent as the context node and appear before the context node in the source document.
self (.)indicates the context node itself. It can be abbreviated as a single period (.).