2

First of all, I apologize if this is pretty similiar in nature to my previous question: Reading and (custom) formatting a CSV (not \csvautotabular)

I thought it would be better to separate the two for future reference.

Also, converting to CSV is not always an option, if you have some serious XMLs.

So, here is the deal - I have an XML file that - suppose - looks like this:

<root>
<foo>
 <bar>Boom</bar>
 <baz>Bang</baz>
</foo>
<foo>
 <bar>Zip</bar>
 <baz>Zoom</baz>
 <bak>Boing</bak>
</foo>
</root>

I would like to obtain something along the lines of:

\begin{Foo}
  \Bar{Zoom}
  \Baz{Bang}
\end{Foo}
\begin{Foo}
  \Bar{Zip}
  \Baz{Zoom}
  \Bak{Bang}
\end{Foo}

ATM I'm doing this with a couple of python lines the output of which I then proceed to \include it in my main file, but it would be nice not having to depend on an external script, especially since I'm not the only one working on the document.

Any hint is appreciated.

  • 7
    xmltex is an xml parser written in tex, and can be used for including xml in exactly this way. (although personally I'd use XSLT to generate the tex syntax from the XML) despite having written xmltex:-) – David Carlisle Aug 22 '14 at 9:42
  • +1 for XSLT--fantastic tool. xsltproc is your friend. If you want fancier things, saxon is pretty neat, too. – Sean Allred Aug 25 '14 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.