in reply to Perl Hash to XML

If you can sacrifice your requirement to append to an existing file, than XML::Simple can do it. Might be even saver to work with two files for smaller sets of data (XMLin file / modify data in memory / XMLout new file)?

Replies are listed 'Best First'.
Re^2: Perl Hash to XML
by Bugz (Acolyte) on Aug 18, 2008 at 21:06 UTC
    so if i got it right, you are suggesting that i copy contents from an existing file, and push it into a new file(new by name of just replacing the old one) along with the additional data i am pushing in this time. :)

    sure XML::SIMPLE would do that, but there's ought to be a simpler way. right?
      It depends... Do you mean simple in the sense of performance? Well, who says that your existing XML file has to be treated as such (parsed and validated)? Seek to the end of the file, before the </a>, add another <b>...</b></a> sequence and done. But I guess, you want a little bit more than that...and a little bit more robustness?
      The previous suggestion is simple to program, but surely not the fastest way to append a node to a (potentially large) file.
        i think i could do with that, my xml files would only contain two to max 3 child nodes. each one added one at a time.

        So i guess I could use this approach. Which is not the best approach considering robustness, but again, simplicity is the requirement...

        however, it would be nice to learn how to do it in a more robust way esply since I have another task on hand where have more than 200 nodes.