Tool.Yun
Uirlisí úsáideacha do fhorbróirí
Áireamhán Amúchta
Bileog Cheat Bash
Bileog Cheat Comhréire JSONPath
Bileog Cheat Comhréire XPath
Bileog Cheat Docker
Bileog Cheat Jq
Bileog Cheat K8s
Bileog Cheat Markdown
Bileog Cheat Nano
Bileog Cheat Ordú Scáileáin
Bileog Cheat Ordú Tmux
Bileog Cheat Ordú Zellij
Bileog Cheat Ordú chmod
Bileog Cheat Powershell
Bileog Cheat Regex Choitianta
Bileog Cheat Roghnóirí CSS
Bileog Cheat Tiomnais Seimeantach Git
Bileog Cheat VIM
Bileog caimiléir Git
Bileog cheat Docker Compose
Bileog cheat Docker SWARM
Bileog cheat Dockerfile
Bileog cheat Regex
Bileog cheat Sed
NBileog Cheat ginx
Flipper Bonn
Roghnóir Cártaí
Rollóir Dísle
Roth an fhortún
Argon2 Hasher
Bcrypt
Beart Niceware go Frása Pasfhocail
Cripteagrafaíocht AOIS
Criptigh / díchriptiú téacs
Criptithe cruinneachán Ansible a dhíchriptiú
Criptiú Comhaid PGP
Criptiú PGP
Criptiú RSA
Criptiú Teaghrán Jasypt
Eochairghiniúint PGP
Gineadóir CSR
Gineadóir JWT
Gineadóir péire eochracha Ed25519
Gineadóir péirí eochracha ECDSA
Gineadóir teastais X509
Hais Comhaid
Hais téacs
Hmac gineadóir
Ionchódóir/Díchódóir Bech32
Parsálaí JWT
Parsálaí SAML
Parsálaí Teastais/Eochrach
Paseto/PASERK Poiblí/Príobháideach
Paseto/PASERK Áitiúil
RSA gineadóir eochair péire
Roinnt Rúnda Shamirs
Sínitheoir agus Fíoraitheoir RSA/DSA/ECDSA
Tiontaire Teastais SSL
Áireamhán CRC
Bailíochtóir GTIN
Díchódóir Cód QR
Gineadóir Faisnéise Teagmhála QR
Gineadóir barrachóid
Gineadóir cóid QR
Gineadóir cóid QR WiFi
Léitheoir Barrachóid
tools.epc-qrcode-generator.name
Bailíochtóir Cumadóireachta Docker
Docker Compose chuig comhad .env
Docker Compose go Quadlets
Docker compose go kubernetes
Docker iniúchta le haghaidh rith Docker
Déantóir Cumadóireachta Docker Traefik
Gineadóir Lipéad Dockerfile
Gineadóir RBAC Kubernetes
Lipéid Docker Pangolin
Rith Docker go Kubernetes
Rith Docker go Quadlets
Rith docker chuig tiontaire cumadóireachta Docker
Tiontaire Formáide Docker Compose
Tiontaire rith Docker Compose go Docker
Íoslódálaí Íomhánna Docker
Aláram Ama
Aláram Cron/Laethanta na Seachtaine
Comhaireamh síos
Cróniméadar
Cumaisc iCal
Cén Lá?
Gineadóir ICAL
Parsálaí Comhad ICAL
Tiontaire Crios Ama
Tiontaire Uimhreacha Seachtaine
Tiontaire dáta-am
Áireamhán Dáta+Fad
Áireamhán ETA
Áireamhán Fad
Áireamhán Laethanta
Áireamhán TTL
Ríomhaire Aclaíochta
Tiontaire Aonaid Achar
Tiontaire Aonaid Brú
Tiontaire Aonaid Fad
Tiontaire Aonaid Fuinnimh
Tiontaire Aonaid Fórsa
Tiontaire Aonaid Mais
Tiontaire Aonaid Toirte
Tiontaire Aonaid Uillinne
Tiontaire Cumhachta
Tiontaire Fuinnimh Bia
Tiontaire Luas
Tiontaire Luasghéaraithe
Tiontaire Minicíochta
Tiontaire Ráta Sreafa Toirte
Tiontaire Réimíreanna SI
Tiontaire Soilsiúcháin
Tiontaire teochta
Aibhsitheoir Cód/Scripteanna
Amaire Pomodoro
Bréigeoir Sonraí
CSS/JS Áilleachtú & Laghdaigh
Ceo Javascript
Dí-chomhbhrúiteoir/Díphacáileoir Javascript
Eagarthóir orduithe Cli
Gineadóir Favicon
Gineadóir GitIgnore
Gineadóir Mailto
Gineadóir Paraiméadair SQL
Gineadóir Rúnda Django
Gineadóir Scripteanna Tástála Ualaigh K6
Gineadóir Tréithe Git
Gineadóir Tábla Bunachar Sonraí
Json go Protobuf
Json go SQL INSERT
Json go Typescript
Miniféir SQL
Oscail gineadóir meta graf
SQL prettify agus formáid
Scoilteoir Comhad
Stacktrace níos deise
Tiontaire Comhad HEX
Tiontaire Lua
Tiontaire Lúb
Tástálaí API
Tástálaí Chomhéadain Swagger
Tástálaí Picomatch
Tástálaí Éalaithe ANSI
Tógálaí Cruthaithe Bunachar Sonraí
Tógálaí Teaghrán Ceangail Bunachar Sonraí
Áillitheoir Javascript
Éalaitheoir Teaghrán
Anailíseoir Tuairiscí DMARC
Bileog Cheat Sreangaithe RJ45 Cat6
Brathadóir Cineál Comhaid
Brathadóir/Díchódóir Tacair Charachtair Téacs
Consól Port Sraitheach
Cuardaitheoir airíonna LDAP ActiveDirectory
Díchódóir EMV TLV
Díchódóir Idirbhirt ETH
Díchódóir Safelink Outlook
Díchódóir Url Comhroinnte SharePoint
Eastóscóir aitheantais calóga sneachta
Faisnéis eochairchóid
Gineadóir TCPDump
Ionchódóir/Díchódóir Heicsidheachúlach
Leathnaitheoir URLanna Gearra
Léitheoir comhaid Parquet
Mascóir sonraí íogaire
Parsálaí Fianán
Parsálaí MSG Outlook
Parsálaí Ríomhphoist
Parsálaí Ríomhphoist Preabtha
Parsálaí URL
Tiontaire GZip/Díbhoilscithe
Tiontaire IdRéadaí MongoDB
Tiontaire Ionchódaithe MIME
Tiontaire Meán-Endian
Tiontaire SMART Raw
Tiontaire uimhir snámhphointe
Tástálaí DNS
Tástálaí HTTPS
Tástálaí Ilphlandúcháin DNS
Tástálaí Picteil Marbh
Tógálaí Ordú Nmap
Tógálaí URL
Áireamhán Friotóra
键盘测试器
Gineadóir Cód PIN
Gineadóir Frása Pas
Gineadóir NanoIDanna
Gineadóir Pasfhocal Diceware
Gineadóir UUIDs
Gineadóir comhartha
Gineadóir cóid OTP saor in aisce,
Gineadóir pasfhrása BIP39
Gineadóir uimhreacha
Gineadóir uimhreacha randamacha
Tiontaire UUID
Cineálacha MIME
Cóid stádais HTTP
Déantóir Blúirí Cuardaigh Téacs Url
Eagarthóir HTML WYSIWYG
Eolas gléas
Gabhálaí Url
Gineadóir Grádáin CSS
Gineadóir URL UTM
Gineadóir áitsealbhóirí SVG
Glantóir Html
Glantóir URL
HTML go XHTML
HTML go sonraí
Ionchódaigh/díchódaigh teaghráin formáidithe URL
Laghdaitheoir HTML
Parsálaí úsáideora-ghníomhaire
Roth Dathanna
Seiceálaí Codarsnachta Datha
Slabhra sluga a chruthú
Tiontaire Aonad CSS
Tiontaire CSS XPath
Tiontaire datha
Tiontaire picteilín REM
Áillitheoir CSS
Áillitheoir Html
Éalú aonáin HTML
Íomhá go CSS
Anailíseoir Méid Json
CSV go JSON
Cumaisc JSON
Cód Json go PHP
Difríocht JSON
Eagarthóir JSON
Iarratas Json
JSON Leacaitheoir/Díleacaitheoir
JSON Linter
JSON ceartaigh agus formáid
JSON chuig an Eintiteas Java
JSON go .env
JSON go C#
JSON go CSV
JSON go Go
JSON go MessagePack
JSON go Sonraí
JSON go TOML
JSON go TS
JSON go XML
JSON go réad
Json go PHP-Array
Json go Python
Json go SQL DDL
Json go Scéim
Laghdaigh JSON
Máistir sórtála JSON
ObjGen go JSON
PHP-Eagar go JSON
Pacáiste Teachtaireachta chuig JSON
Tiontaire JS go JSON
Tiontaire JSON go JS
Tiontaire JSON go YAML
Tiontaire teaghrán Json
Tástálaí Jq/JSONPath
tools.json-patch.name
Éalú Json/Unescape
Anailíseoir neart pasfhocal
Bileog Cheat ZPool
Cuardach seoladh MAC
Díchódóir ARPA
Díchódóir X-VR-SpamCause
Fiosrúcháin DNS
Forbróir raon IPv4
Formáideoir Nginx
Formáideoir Orduithe Shell
Geoshuíomh IP
Gineadóir Crontab
Gineadóir Cumraíochta Wireguard
Gineadóir DMARC DNS
Gineadóir DNS BIMI
Gineadóir DNS DKIM
Gineadóir DNS PTR
Gineadóir DNS SPF
Gineadóir FStab
Gineadóir HTAccess
Gineadóir Htpasswd/htaccess
Gineadóir Iptables
Gineadóir LogRotate Apache
Gineadóir Option43
Gineadóir Orduithe Múchta
Gineadóir Ordú Curl
Gineadóir Ordú UFW
Gineadóir Rsync
Gineadóir WPA PSK
Gineadóir port randamach
Gineadóir seoladh MAC
Gineadóir údaraithe bunúsach
IPv4-6/IPRange/CIDR in IPRange/CIDR/IPMask
IPv6 gineadóir ULA
Iarratais DNS/RDAP Cloudflare
Liosta Fo-líonra IPv4
Línearaitheoir Orduithe Shell
Mo Sheoladh IP
Neart Pasfhocal Zxcvbn
Ping
Seiceálaí DNSBL
Seiceálaí Whois
Sláintitheoir HAR
Slánuimhreacha chuig IPv4/IPv6
Tiontaire Punycode
Tiontaire Seoladh MAC
Tiontaire seoladh IPv4
Tiontaire seoladh Ipv6
Tástálaí Calafoirt TCP/UDP
Tástálaí Micreafóin
Tástálaí soicéad gréasáin
Uimhreacha Poirt
gineadóir líne ordaithe firewalld
tools.restic-command-generator.name
tools.url-redirection-checker.name
Áireamhán Chmod
Áireamhán Eisiaimh Fo-líonraí IP
Áireamhán Fo-líonra Amhairc
Áireamhán HDD
Áireamhán Iontaofachta RAID
Áireamhán RAID
Áireamhán RAID ZPOOL
Áireamhán Raoin IP ó CIDR Ipv4/6
Áireamhán Raon IPv4/6 go CIDR(anna)
Áireamhán Ráta Aistrithe Sonraí
Áireamhán fo-líonra Ipv6
Áireamhán subnet IPv4
Íoslódálaí il-naisc
Údarú SIP
Difríocht Marcáil anuas
Eagarthóir Markdown
Epub go Markdown
Gineadóir Tábla Marcála
Gineadóir toc Markdown
Greamaigh mar Markdown
HTML le marcáil síos
Lorem Ipsum Markdown
Marcáil síos ar shonraí
Marcáil síos go DOCX
Marcáil síos go HTML
Marcáil síos go Téacs
Réamhamharc marcála síos
tools.markdown-format-converter.name
Áilleoir Tábla Marcála
Amharcléiritheoir Cuar Triantánach/Cothromóideach
Measúnaí mata
OCR Matamaitice
Tiontaire Formáidí Matamaitice
Áireamhán Dénártha
Áireamhán leideanna
Comhbhrúiteoir PDF
Comhcheanglóir Pdf
Eastóscóir Téacs PDF
HTML go PDF
Pdf Criptithe
Pdf Eastóscóir Leathanach
Pdf Línearú/FastWeb
Pdf a dhíchriptiú agus a dhíghlasáil
Seiceáil sínithe PDF
Tógálaí Léirithe Cron
Bailíochtóir Luhn
Bailíochtóir agus Parsálaí ISBN
Bailíochtóir agus parsálaí IBAN
Bailíochtú Uimhreacha CBL
Comhoiriúnacht ceadúnas bogearraí
Cuardach Unicode
Cuardaitheoir Cód Tíre ISO 3166
Cuardaitheoir ISO 639
Foclóir Ar Líne
Mínigh an tOrdú Shell
Parsálaí agus formáidí fón
Seiceálaí Cárta Creidmheasa
Tiontaire Airgeadra
Tiontaire Cás Uachtarach RMB
Tiontaire Féilire
Treoirlínte Soilsithe IES
Áireamhán BMI
Áireamhán Luas Rith
Áireamhán SLA
TOML Linter
TOML go JSON
TOML go YAML
Csv go Sonraí
Excel go sonraí
Gineadóir ULID
Ionchódóir/díchódóir eagar heicsidheachúlach Base64
Ionchódóir/díchódóir teaghrán Base64
Normalaitheoir ríomhphoist
Ríomhaire Ídiú Fuinnimh agus Costais
Tiontaire Aonad Go Leor
Tiontaire Aonaid Stórála Sonraí
Tiontaire Carachtair Unicode go Eintitis Java
Tiontaire Comhordanáidí Geografacha
Tiontaire Formáid Athróg Comhdhlútha
Tiontaire airíonna
Tiontaire bonn slánuimhir
Tiontaire comhad base64 íoslódáil
Tiontaire dBm mW
Tiontaire uimhreacha Rómhánacha
Torrent go Maighnéad
Téacs go Unicode
Téacs go dénártha UTF-8
Tógálaí tagarmhairc
Áireamhán Cóimheas Gnéithe
Áireamhán achair gheografaigh
Áireamhán céatadánach
Aimsitheoir Línte Dúblacha
Aistritheoir Téacs
Athsholáthar Téacs Cliste agus Briseadh Líne
Bain téacs as HTML
Comhroinnteoir Nasc Sóisialta
Comparadóir Liostaí
Difríocht téacs
Déan Comparáid Clónna
Focail Ar Leith
Formáideoir Unicode
Gineadóir Ordú Sed
Gineadóir Sleachta
Gineadóir Téacs Ealaíne ASCII
Gineadóir an-mhaith
Gineadóir/Meirge Zalgo
Ionchódóir/Díchódóir Comhartha GPT
JSON go TOON
Liosta tiontaire
Léaráid Struchtúr Fillteán
Léitheoir RSVP
Meastóir Comharthaí GPT
Onnmhaireoir maighdeana mara
Pacáil comhaid le haghaidh AI
Roghnóir Emoji
Roghnóir Líní Rándamach
Scoilteoir Pras AI
Scrambalóir slabhra
Seiceálaí I agus L
Staitisticí téacs
TOON go JSON
Tabáil go Spásanna
Tiontaire Cód Morse
Tiontaire Leagan Amach Méarchláir
Tiontaire Rún
Tiontaire cás
Tástálaí Regex
Téacs chuig Ainmneacha Unicode
Téacs go aibítir NATO
Unicode go GSM-7
Áireamhán Levenshtein
Íomhá go hEalaín ASCII
Formáidiú XML
Linter XML
ObjGen go HTML
Tástálaí XPath
Tástálaí XSLT
XML go JSON
Cumasc YAML
Tiontaire YAML go JSON
YAML Leacaitheoir/Díleacaitheoir
YAML go TOML
YAML prettify agus formáid
Athraitheoir íomhá
Bain Cúlra na hÍomhá
Bain EXIF
Comparáid Íomhá
GIF go MP4
Inbhéartóir Dath Íomhá
Léitheoir cáilíochta EXIF/Meiteashonraí/GPS/JPEG íomhá
OCRúigh íomhá agus PDF
Réamhamharcóir SVG
Ríomhairigh íomhá
Taifeadta ceamara
Tiontaire Formáidí Íomhá
Tiontaire HEIC
Tiontaire ICO/PNG
Uiscemharc
Íomhá go SVG (potrace)

Bileog Cheat Comhréire XPath

Bileog Cheat Comhréire XPath

XPath navigates an XML or HTML document as a tree. Every step has the form axis::node-test[predicate], and most of it has a short form: //div[@class="card"]/a/@href reads “the href of every a inside any div with class card”.

⚠️ Browsers, Selenium and most scrapers implement XPath 1.0. ends-with(), matches(), lower-case() and replace() are 2.0+ and only work in tools like xmllint, Saxon or lxml with an XSLT 2.0 processor. Workarounds for 1.0 are given below.

🧭 Path Syntax

XPathSelects
/From the document root — an absolute path
//Anywhere in the document, at any depth
.The current (context) node
..The parent of the context node
@attrAn attribute
*Any element
@*Any attribute
text()The text nodes of an element
node()Any node at all, text and comments included
[n]The nth match — 1-based, not 0-based
[last()]The last match
a | bThe union of two expressions
/html/body            (: absolute: the body of the page :)
//text()              (: every text node :)
./div/b               (: relative to the context node :)
(//p)[2]              (: the second p in the whole document :)
//p[2]                (: every p that is the second p of its parent :)

🏷 Elements & Attributes

XPathDescriptionCSS
//EEvery <E> elementE
(//E)[2]The second <E> in the document—
//E[@A]<E> carrying attribute AE[A]
//E[@A="t"]<E> where A is exactly tE[A='t']
//E[contains(@A,"t")]<E> where A contains tE[A*='t']
//E[starts-with(@A,"t")]<E> where A starts with tE[A^='t']
//E[substring(@A, string-length(@A)-2)="t"]<E> where A ends with t (1.0 trick)E[A$='t']
//E[ends-with(@A,"t")]The same, XPath 2.0+ onlyE[A$='t']
//E[matches(@A,"r")]A matches regex r (2.0+)—
//E/@AThe value of attribute A—
//*/@AAttribute A of any element—
//E[@A2="t"]/@A1A1 where A2 is t—
//E1[@id="I1"] | //E2[@id="I2"]Either elementE1#I1, E2#I2
//E[@id="I1" or @id="I2"]<E> with either idE#I1, E#I2

🆔 Id, Name, Class & Language

XPathDescriptionCSS
//*[@id="I"]The element with id I#I
//E[@id="I"]<E> with id IE#I
//*[@name="N"]Any element named N[name='N']
//*[@name="N"][@value="v"]Named N with value v[name='N'][value='v']
//*[contains(concat(" ", normalize-space(@class), " "), " C ")]Element with class C — the padding avoids matching C2.C
//E[contains(concat(" ", normalize-space(@class), " "), " C ")]<E> with class CE.C
//E[@lang="L" or starts-with(@lang, concat("L","-"))]<E> in language L or a subcodeE[lang|='L']

📝 Text & Links

XPathDescriptionCSS
//*[.="t"]Element whose whole text is exactly t—
//E[contains(text(),"t")]<E> with a text node containing t—
//E[contains(.,"t")]<E> whose text, descendants included, contains t—
//E[normalize-space()="t"]Exact text, ignoring surrounding whitespace—
//aEvery linka
//a[.="t"]The link labelled exactly t—
//a[@href="url"]The link pointing at urla[href='url']
//a[.="t"]/@hrefThe URL behind the label t—
//a[starts-with(@href,"https")]Secure links onlya[href^='https']

👪 Parents & Children

XPathDescriptionCSS
//E/*[1]First child of <E>E > *:first-child
//E/*[last()]Last child of <E>E > *:last-child
//E[1]Each <E> that is the first of its type in its parentE:first-of-type
//E[last()]Last <E> of its typeE:last-of-type
//E[2]Second <E> of its typeE:nth-of-type(2)
//*[2][name()="E"]Second child, if it is an <E>E:nth-child(2)
//E[last()-1]Second-to-last <E> of its typeE:nth-last-of-type(2)
//E/..The parent of <E>—
//div/form/parent::*Every element that has a form childdiv:has(> form)
//*[@id="I"]//E<E> anywhere under id I#I E
//E[count(*)=0]<E> with no element childrenE:empty
//E[count(*)=1]<E> with exactly one child—
//E[count(preceding-sibling::*)+count(following-sibling::*)=0]<E> that is an only childE:only-child
//E[count(../E)=1]<E> with no <E> siblingsE:only-of-type
//E1[E2 and not(*[not(self::E2)])]<E1> whose only children are <E2>—
//E[position() mod N = M + 1]Every Nth element, offset by ME:nth-child(Nn+M)

👥 Siblings

XPathDescriptionCSS
//E2/following-sibling::E1Every <E1> after a sibling <E2>E2 ~ E1
//E2/following-sibling::*[1][name()="E1"]<E1> immediately after <E2>E2 + E1
//E2/following-sibling::*[2][name()="E1"]<E1> two siblings after <E2>E2 + * + E1
//E/following-sibling::*[1]Whatever follows <E> directlyE + *
//E2/preceding-sibling::E1Every <E1> before a sibling <E2>—
//E2/preceding-sibling::*[1][name()="E1"]<E1> immediately before <E2>—
//E/preceding-sibling::*[1]Whatever precedes <E> directly—

📊 Tables & Form State

XPathDescriptionCSS
//*[@id="T"]//tr[3]//td[2]Third row, second cell#T tr:nth-child(3) td:nth-child(2)
//td[preceding-sibling::td="t"]The cell right after the one reading t—
//td[preceding-sibling::td[contains(.,"t")]]Cells following one containing ttd:has(~ td)
//table[count(tr)=1 and count(tr/td)=2]Tables with one row and two columns—
//table/tr[last()]The last row of a tabletable tr:last-child
//E[@disabled]A disabled controlE:disabled
//E[not(@disabled)]A control that is not disabledE:enabled
//*[@checked]A checked checkbox or radio:checked

🧮 Functions

Strings

FunctionReturns
contains(haystack, needle)True when the first string contains the second
starts-with(haystack, needle)True when it starts with it
concat(s1, s2, …)The strings joined together
normalize-space(s)The string with runs of whitespace collapsed and trimmed
string-length(s)The number of characters
substring(s, start [, length])A slice — 1-based
substring-before(haystack, needle)Everything before the first occurrence
substring-after(haystack, needle)Everything after it
translate(s, from, to)Characters mapped one by one — the 1.0 way to fold case

Numbers, logic & nodes

FunctionReturns
count(node-set)How many nodes matched
sum(node-set)The sum of their numeric values
position()The index of the context node within its step
last()The size of the context — so [last()] is the final node
name([node-set])The qualified name of the first node
namespace-uri([node-set])Its namespace URI
lang(s)True when the node is in that language
not(expr)The negation
true() / false()Boolean constants
boolean(expr) / string(o) / number(o)Type conversions
ceiling(n) / floor(n) / round(n)Rounding

💡 Case-insensitive matching in XPath 1.0: //E[contains(translate(@A,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz"), "t")]

🧭 Axes

AxisShort formSelects
child(default)The direct children of the context node
descendant//Every node below the context node
descendant-or-self//The context node and everything below it
parent..The single parent node
ancestor—Parent, grandparent, up to the root
ancestor-or-self—The same, including the context node
following—Everything after the node in document order, except descendants
following-sibling—Later siblings under the same parent
preceding—Everything before it, except its ancestors
preceding-sibling—Earlier siblings under the same parent
attribute@The attributes of the node
self.The context node itself
//td[.="Total"]/ancestor::table          (: the table a cell belongs to :)
//h2[.="Specs"]/following-sibling::ul[1] (: the list after a heading :)
//input[@name="q"]/ancestor-or-self::form (: the form wrapping a field :)

🧠 Worked Examples

//hr[@class="edge" and position()=1]
(: the first hr of class 'edge' under each parent :)

//table[parent::div[@class="pad"] and not(@id)]//a
(: links in unnamed tables inside a padded div :)

/html/body/div/*[preceding-sibling::h4]
(: whatever comes after an h4 :)

//tr/td[font[@class="head" and text()="TRACK"]]
(: cells whose font child says TRACK :)

//*[count(*)=3]
(: elements with exactly three children :)

//rdf:Seq/rdf:li/em:id
(: namespaced elements — the prefixes must be bound by the host tool :)

//var | //acronym
(: a union of two node sets :)

🛠 Running XPath

// browser devtools console
$x('//a[contains(@href, "docs")]');

// plain DOM API
document.evaluate('//h1', document, null, XPathResult.ANY_TYPE, null).iterateNext();
# from the shell, over XML or HTML
xmllint --xpath '//book/title/text()' catalog.xml
xmllint --html --xpath '//a/@href' page.html 2>/dev/null
from lxml import html
tree = html.parse('page.html')
tree.xpath('//div[@class="card"]/a/@href')
# Selenium and Playwright both accept XPath locators
driver.find_element(By.XPATH, '//button[normalize-space()="Save"]')
page.locator('xpath=//button[normalize-space()="Save"]').click()

⚠️ Notes

  • Indexes start at 1. [0] never matches anything.
  • //E[1] is per-parent, (//E)[1] is document-wide — the single most common XPath bug.
  • Namespaced documents need prefixes registered with the host library; in XPath 1.0 a common workaround is //*[local-name()="title"].
  • // is expensive on large documents; anchor the path when you can.
  • Prefer text matching with normalize-space() — HTML is full of stray whitespace and line breaks.

📚 Resources

  • MDN — XPath
  • MDN — XPath functions
  • XPath 1.0 specification
  • XPath cheat sheet (alephzarro)

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