1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-23 16:42:08 +02:00
tldr/pages/common/xml-select.md
Vitor Henrique 46a054215a
pages*: make help and version commands comply with the style guide (#12107)
* pages*: use generic word for help

* git: add newline to the end

Co-authored-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>

* pages*: make help and version commands comply with the style guide

* java: fix Java name

---------

Co-authored-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>
2024-01-30 12:55:24 +08:00

25 lines
903 B
Markdown

# xml select
> Select from XML documents using XPATHs.
> Tip: use `xml elements` to display the XPATHs of an XML document.
> More information: <http://xmlstar.sourceforge.net/docs.php>.
- Select all elements matching "XPATH1" and print the value of their sub-element "XPATH2":
`xml select --template --match "{{XPATH1}}" --value-of "{{XPATH2}}" {{path/to/input.xml|URI}}`
- Match "XPATH1" and print the value of "XPATH2" as text with new-lines:
`xml select --text --template --match "{{XPATH1}}" --value-of "{{XPATH2}}" --nl {{path/to/input.xml|URI}}`
- Count the elements of "XPATH1":
`xml select --template --value-of "count({{XPATH1}})" {{path/to/input.xml|URI}}`
- Count all nodes in one or more XML documents:
`xml select --text --template --inp-name --output " " --value-of "count(node())" --nl {{path/to/input1.xml|URI}} {{path/to/input2.xml|URI}}`
- Display help:
`xml select --help`