On Tue, 15 Nov 2005, Nick Rout wrote:

I want to manipulate some XML stuff, including:

Personally I favour ruby+rexml for such a task. It has document at once mode and a SAX mode like Carl's python example.

Another option is xmlstarlet it is available as a debian package or from...

xmlstarlet --help
XMLStarlet Toolkit: Command line utilities for XML
Usage: xml [<options>] <command> [<cmd-options>]
where <command> is one of:
  ed    (or edit)      - Edit/Update XML document(s)
  sel   (or select)    - Select data or query XML document(s) (XPATH, etc)
  tr    (or transform) - Transform XML document(s) using XSLT
val (or validate) - Validate XML document(s) (well-formed/DTD/XSD/RelaxNG)
  fo    (or format)    - Format XML document(s)
  el    (or elements)  - Display element structure of XML document
  c14n  (or canonic)   - XML canonicalization
  ls    (or list)      - List directory as XML
  esc   (or escape)    - Escape special XML characters
  unesc (or unescape)  - Unescape special XML characters
pyx (or xmln) - Convert XML into PYX format (based on ESIS - ISO 8879)
  p2x   (or depyx)     - Convert PYX into XML
<options> are:
  --version            - show version
  --help               - show help
Wherever file name mentioned in command help it is assumed
that URL can be used instead as well.

Type: xml <command> --help <ENTER> for command help

XMLStarlet is a command line toolkit to query/edit/check/transform
XML documents (for more information see http://xmlstar.sourceforge.net/)


It basically seems to be a command line wrapper on XSLT. (Beware, there be Dragons.)

I'll admit I make frequent use of xmlstarlet validate and element structure facilty.

eg.

xmlstarlet el http://www.clug.org.nz
html
html/head
html/head/meta
html/head/meta
html/head/meta
html/head/meta
html/head/meta
html/head/meta
html/head/meta
html/head/meta
html/head/meta
html/head/meta
html/head/base
html/head/link
html/head/link
html/head/link
html/head/link
html/head/link
html/head/link
html/head/link
html/head/link
html/head/link
html/head/link
html/head/link
html/head/link
html/head/link
html/head/link
html/head/style
html/head/title
html/body
html/body/div
html/body/div/div
html/body/div/div/a
html/body/div/div/a/img
html/body/div/div
html/body/div/div/form
html/body/div/div/form/input
html/body/div/div/form/div
html/body/div/div/form/div/a
html/body/div/div/form/div/a/img
html/body/div/div/form/div/a
html/body/div/div/form/div/a/img
html/body/div/div/form/div/input
html/body/div/div/form/div/input
html/body/div/div/form/div/input

Useful to understand the structure of an xml doc

John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email : [EMAIL PROTECTED]
New Zealand

Carter's Clarification of Murphy's Law.

"Things only ever go right so that they may go more spectacularly wrong later."

From this principle, all of life and physics may be deduced.

Reply via email to