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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
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 Sat, 13 Dec 2014 23:07:12 +0000
Lines 31
Message-ID <cf3v50Fk9q7U1@mid.individual.net> (permalink)
References <12ba7341-3328-44b6-8b03-4c651f8dbce3@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252
Content-Transfer-Encoding 8bit
X-Trace individual.net 3oGUHs61TjKQ864XxG3RYg+++lgcH8xWGWvl/btDevLirkHcn+
Cancel-Lock sha1:6255LCF3Mrp2vOXPDRbbli0b+YA=
User-Agent Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.3.0
In-Reply-To <12ba7341-3328-44b6-8b03-4c651f8dbce3@googlegroups.com>
Xref csiph.com comp.text.xml:799

Show key headers only | 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