LinuxCommandLibrary

xml-select

Query XML documents with XPath

TLDR

Select nodes with XPath

$ xml select -t -v "[//element]" [file.xml]
copy
Extract multiple values
$ xml select -t -m "[//item]" -v "[@name]" -n [file.xml]
copy
Select with namespace
$ xml select -N [ns=http://example.com] -t -v "[//ns:element]" [file.xml]
copy
Copy matching nodes
$ xml select -t -c "[//element]" [file.xml]
copy

SYNOPSIS

xml select [options] xpath [file...]

DESCRIPTION

xml select queries XML documents using XPath expressions. Part of xmlstarlet toolkit. Extracts values, attributes, and node sets from XML files.

PARAMETERS

-t, --template

Start template.
-v, --value-of xpath
Output value of XPath expression.
-m, --match xpath
Match XPath expression.
-c, --copy-of xpath
Copy matching nodes.
-n, --nl
Output newline.
-N prefix=uri
Define namespace prefix.
-T
Text output mode.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community