On 14/12/11 19:50, Joe Kesselman wrote:
> On 12/14/2011 6:56 AM, ~ el commandante ~ wrote:
>> i am looking for a xml2array or xml2list code.
>
> Your question can't be answered as you've posed it.
>
> XML is tree-structured data. How you convert that to an array or list is
> going to depend on what kind of document you're working with, what
> information you want to extract out of it, and how you want to organize
> that information.
>
> What are you actually trying to do? Specify exactly what kinds of input
> you want to process, and exactly what output you want to produce, and an
> answer becomes possible.
You could start with the little demo I wrote many years ago which
converts an XML document to a CSV file. This is only meaningful for
"data" XML (I shudder to think what you would get if you tried it on a
TEI or DocBook document :-)
The code is at
http://www.silmaril.ie/downloads/software/xml2csv/xml2csv.zip and I
assume it still works, but it comes with no guarantees whatsoever :-)
(Incidentally, when I demo'd this at a course I taught at an early
SGML/XML conference, I was approached by an irate gentleman afterwards
who had just spent $30,000 on a consultant to write a C program to do
the same thing. He wanted to know what the hell I thought I was doing
making public a few lines of awk script...:-)
///Peter