XML source

Xul scripts require an XML source to operate on. An XML source can be a local file, an URL (HTTP or FTP) or a pipe.

File

With xp you can select nodes in a local XML file with an XPath expression:

xp 'node()' entity.xml

Pipe

Redirect output (pipe) to a Xul script:

curl -s https://developer.apple.com/news/rss/news.rss | ppx

URL

libxml2 also supports loading XML through HTTP (and FTP). For example, to pretty print an RSS feed:

ppx http://feeds.launchpad.net/pytz/announcements.atom

Loading XML through HTTPS is not supported and will result in an failed to load external entity error. Try redirecting the HTTPS URL output to a Xul script. See the curl example above.

Examples

XHTML [1] is part of the family of XML markup languages. It’s obsolete.

Pretty print an XHTML document:

curl -s https://www.webstandards.org/learn/reference/templates/xhtml11/ | ppx

Validate an XHTML document with the XHTML 1.0 strict DTD:

curl -s https://www.webstandards.org/learn/reference/templates/xhtml10t/ | validate -d examples/dtd/xhtml1-transitional.dtd

Print the link destinations in an XHTML document:

curl -s https://www.w3.org/1999/xhtml/ | xp -d html "//html:link/@href"

More XSDs and DTDs examples can be found in the Xul GitHub repository.

See also

Xul scripts: ppx, xp, validate, transform

Footnotes