2

I would like to automate creating a flat list/array type structure in a language such as Ruby,Python etc that takes XML data and for each node builds a list/array entry that contains the data plus data type information obtained from its XML Schema.

Any pointers to a solution appreciated.

Cheers.

John
  • 21
  • 1
  • Have you tried anything yet? `nokogiri` in Ruby, for example? (As a bonus, [a tweet by Jeff](https://twitter.com/#!/codinghorror/status/121881520641277952).) – rdvdijk Oct 06 '11 at 11:09
  • have the same problem, lxml validation does not help – Dill Oct 22 '13 at 09:18

1 Answers1

0

In python, there are several xml parsing libraries, but I'd recommend lxml. Then, it's a piece of cake. Just iterate through your xml and this way you have access to data, attributes etc. Filling a list out of them is trivial. Just a little experimentation...

hymloth
  • 6,869
  • 5
  • 36
  • 47
  • I am not sure how traversing the XML file references the data types from XML Schema file though? – John Oct 06 '11 at 12:22
  • 1
    Thanks. Sorry to sound like a numpty but I can only see examples of how it validates against the Schema but not how to extract the Schema information during a traverse of the XML data. – John Oct 06 '11 at 12:54