in reply to Re^3: Trees in XML
in thread Trees in XML

I need to keep the parsed file in order as I am parsing out the value of the firstname and using it in a SQL query which then gives me a result which I will place back into the same position as the firstname value. I am aware that this is a complicated procedure and as I said I am a newbie to perl and so I am trying to boil down the solution into smaller, bitesize pieces so that I can learn and understand each step!

So any clues or explanation would be great

Thanks

Replies are listed 'Best First'.
Re^5: Trees in XML
by mirod (Canon) on Jun 03, 2008 at 13:33 UTC

    Is the output you want the same XML document you are reading, with the first name replaced by the result of a query? In that case Tree is probably not the style you want to use. Stream or Subs would be easier to use, at least because they take care of copying the data you don't want to process as is. It still won't be as convenient as a higher-level module though, you will still have to write a bit of code yourself. At least you will have to output back the tags you are processing, and escape the text you want to insert.

    BTW, I have always tried to keep XML::Twig installation as simple as possible, so if you're using perl 5.8.*, you should be able to drop the Twig.pm file from the distribution either in you Perl's library XML directory, or just in a sub-directory named XML of the current directory.