in reply to Converting a data structure to XML

I find that rolling your own is the best way to create XML, especially when you have simple, consistent and well understood data structures like the above. Its much faster and simpler than using any parser. To then parse that XML, or alter it after its initial creation, use a parser.

-stvn

Replies are listed 'Best First'.
Re: Re: Converting a data structure to XML
by chromatic (Archbishop) on Jan 14, 2004 at 18:48 UTC

    By all means, if your needs are simple, this is workable. When you get to more complicated things, though, where encoding, namespaces, and character sets come into play, it can be more work to make a simple printer work than it is to use a module that's already solved those problems.

    Update: I don't think printing XML is stupid. It just has a nasty tendency to become very complicated. :)

      Quite true.

      I was not aware of XML::Simple, and after seeing the example by broquaint, I withdraw my original comment. Use that (if it meets your needs of course).

      I find I spend much less time writing my XML documents, and alot more time parsing, manipulating, transforming, etc etc etc. And 9 times out of 10 I end up writing quick one-off scripts to build that initial XML document.

      But, nuff said, I concede the stupidity of my initial remark.

      -stvn