Monk 1: What X should I use?
Monk 2: My favourite is a.
Monk 3: Oh, I always use b. b rules!
Anonymonk 1: Oh, come on, b is the sux0r! It can't even handle z properly
Monk 3: Can't we just get rid of anonymonks? They're such a pain.
Monk 4: Everyone I know is using c. Seems to do the job for me ...
Translation: oi, you could start a flamewar with a question like that. :-)
I may not have many tools in my XML toolbox, but XML::Twig has seemed to handle everything so far. Admittedly it won't handle "bad" XML as Ovid is trying to do, but for "good" XML production, I've been quite happy with XML::Twig. My requirements when I chose XML::Twig were to be able to read in an XML template, look up data from other data sources, process it, and insert transformed data into the XML template, and then have that parsed/used by a Java application where order usually mattered. XML::Twig allowed me to turn around that project in a matter of time that impressed me. YMMV
| [reply] |
There are tons of modules that let you write XML. <snark>Which one you want to use depends upon which set of bugs you want to avoid</snark>.
Seriously, XML::Genx and XML::Writer are both fairly decent thought getting namespaces to work can be excruciatingly painful.
| [reply] |
FYI - XML::Writer does allow you to generate invalid XML. You just have to turn off the well-defined check(s) that you're violating. :-)
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
| [reply] |
Part of the problem with that module is explained in the bug report I just filed. Namespaces are handled poorly. Also, I don't know that it allows me to insert unescaped data between tags. I know I should do that, but I don't have a choice. There are some really, really bad XML "variants" out there.
| [reply] |
| [reply] |
Any XML generator module that you use will have the same problem with regard to tag ordering. If you need to get tag a and then tag b in the right order, it's really up to you to do that. Usually, the best way is a small wrapper library on top of whatever XML generator you're using.
As to which one, I have to point out XML::Genx, which I wrote (well wrote the XS interface anyway). It's very, very careful about making damned sure that you don't end up with non-well-formed XML. That means that you'll either produce parseable XML, or get an exception. If you make it produce non-well-formed XML, it's a bug.
-Dom | [reply] |
I just modified my code so that attributes are passed in an array reference instead of a hash reference, thus preserving attribute order.
Update: I modified it again so it takes either a hashref or an arrayref.
| [reply] |