← 返回命令列表

Linux command

xml 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Validate XML

xml val [file.xml]

Format/pretty print

xml fo [file.xml]

XPath query

xml sel -t -v "[//element]" [file.xml]

Transform with XSLT

xml tr [transform.xsl] [file.xml]

Edit in place

xml ed -u "[//node]" -v "[value]" [file.xml]

说明

xml is the main command of XMLStarlet, a comprehensive command-line XML toolkit for querying, editing, validating, and transforming XML documents. It provides a set of subcommands that cover common XML processing tasks without requiring a full programming language. Key subcommands include val for validating XML against DTDs or schemas, fo for pretty-printing and reformatting XML, sel for selecting data using XPath expressions, ed for editing XML elements and attributes in place, and tr for applying XSLT transformations. Each subcommand has its own set of options tailored to its specific operation. XMLStarlet is designed for shell scripting and automation, allowing XML processing tasks to be integrated into pipelines and build scripts. It reads from files or stdin and writes to stdout, following Unix conventions for composability.

参数

val
Validate.
fo
Format.
sel
Select (XPath).
tr
Transform.
ed
Edit.
-t -v _XPATH_
Template value.

FAQ

What is the xml command used for?

xml is the main command of XMLStarlet, a comprehensive command-line XML toolkit for querying, editing, validating, and transforming XML documents. It provides a set of subcommands that cover common XML processing tasks without requiring a full programming language. Key subcommands include val for validating XML against DTDs or schemas, fo for pretty-printing and reformatting XML, sel for selecting data using XPath expressions, ed for editing XML elements and attributes in place, and tr for applying XSLT transformations. Each subcommand has its own set of options tailored to its specific operation. XMLStarlet is designed for shell scripting and automation, allowing XML processing tasks to be integrated into pipelines and build scripts. It reads from files or stdin and writes to stdout, following Unix conventions for composability.

How do I run a basic xml example?

Run `xml val [file.xml]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does val do in xml?

Validate.