Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.text.xml > #799

Re: Basex xml and parsing to csv - XML Newbie needs a kick in right direction

From Peter Flynn <peter@silmaril.ie>
Newsgroups comp.text.xml
Subject Re: Basex xml and parsing to csv - XML Newbie needs a kick in right direction
Date 2014-12-13 23:07 +0000
Message-ID <cf3v50Fk9q7U1@mid.individual.net> (permalink)
References <12ba7341-3328-44b6-8b03-4c651f8dbce3@googlegroups.com>

Show all headers | View raw


On 12/10/2014 03:27 AM, Sayth Renshaw wrote:
[...]
> What should I read know and do? It is possible to convert easily out
. to csv using selectors so I can analyse subsections in csv isn't it?

I use lxprintf (part of the LTxml2 toolkit from Edinburgh at
http://www.ltg.ed.ac.uk/software/ltxml2.html). This lets you identify
and extract data from XML documents and format the output.

For example given test.xml:

<record>
  <name>Sayth Renshaw</name>
  <birth YYYY-MM-DD="2000-01-01"/>
  <job>XML Genius</job>
</record>

You could write

$ lxprintf -e record "\"%s\",%s,\"%s\"\n" name birth/@YYYY-MM-DD job
test.xml

and get the CSV output:

"Sayth Renshaw",2000-01-01,"XML Genius"

If you have really complex requirements, however, you'd be better off
learning XSLT2, which is the transformation language most people use to
convert XML to other formats.

///Peter

Back to comp.text.xml | Previous | NextPrevious in thread | Find similar


Thread

Basex xml and parsing to csv - XML Newbie needs a kick in right direction Sayth Renshaw <flebber.crue@gmail.com> - 2014-12-09 19:27 -0800
  Re: Basex xml and parsing to csv - XML Newbie needs a kick in right direction Peter Flynn <peter@silmaril.ie> - 2014-12-13 23:07 +0000

csiph-web