Home > xml2flat

xml2flat

Xml2flat is a project mainly written in Python, based on the GPL-3.0 license.

Flatten XML documents into CSV-files by specifying some XPath expressions

xml2flat(1) xml2flat(1)

NAME xml2flat - flatten XML files by specifying some XPath expressions

SYNOPSIS xml2flat [OPTIONS] LOOPEXPRESSION COLUMNEXPRESSION...

DESCRIPTION xml2flat takes an XML document from a file or standard input, eval‐ uates the XPath expression LOOPEXPRESSION and iterates over the resulting nodelist. For each node in this list each COLUMNEXPRES‐ SION is evaluated (with the found node as context) and the content of the first node addressed by COLUMNEXPRESSION is printed to stan‐ dard output, delimited with TAB characters.

OPTIONS -f INPUTFILE read data from INPUTFILE instead of STDIN

   -d DELIMITER
          use DELIMITER instead of Tab as field delimiter when  print‐
          ing columns

   -n NAMESPACEPREFIX NAMESPACEURL
          register  namespace NAMESPACEURL as NAMESPACEPREFIX. Needed,
          if the document uses namespaces.

   -s     stop if column-node was not found. Usually, when a node  for
          some  column  is  not  found, an empty string is returned at
          this position. When specifying -s, xml2flat will  exit  with
          an error instead.

XPATH EXPRESSIONS xml2flat uses libxml2 to parse the document and evaluate the LOOP‐ EXPRESSION and COLUMNEXPRESSIONs. So these have to be in a XPath syntax that libxml2 understands. You can find a nice tutorial on XPath here: http://www.w3schools.com/xpath/

EXAMPLES You can find examples on how to use xml2flat at the wiki: https://github.com/stefanschramm/xml2flat/wiki

AUTHOR Stefan Schramm [email protected]

                           NOVEMBER 2010                   xml2flat(1)