Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: XML::Simple Oddities and/or Philosophy

by leriksen (Curate)
on Sep 27, 2005 at 07:03 UTC ( #495294=note: print w/replies, xml ) Need Help??

in reply to XML::Simple Oddities and/or Philosophy

In my opinion, XML::Simple is not the tool to use for this kind of work, especially as the complexity of your XML documents increases

XML::Simple is a great tool for

  • reading XML into a perl data structure
  • writing a perl data structure out to XML where the actual layout doesnt matter, only the well-formedness

By that second point I mean, you aren't contrained by someone elses DTD or XSD - there layout is important e.g. the <name> element must come before the <address> element if the XSD says so, but because XML::Simple is outputting a hash with 'name' and 'address' keys, you cant control that (well, you can, but you have to tie the hash to a package that will sort the keys for you)

In my opinion, if your going to be writing elements/nodes to an XML document, and you dont want to perturb any other parts of the document, your better off using an XML module that supports XPath navigation to locate your insert point, and using its API to insert the required nodes.

This is more robust than tweaking XML::Simple's many options to keep the source and result documents the same.

Another option is XSLT, but that's a whole other technology to master...

...reality must take precedence over public relations, for nature cannot be fooled. - R P Feynmann

  • Comment on Re: XML::Simple Oddities and/or Philosophy

Replies are listed 'Best First'.
Re^2: XML::Simple Oddities and/or Philosophy
by osunderdog (Deacon) on Sep 28, 2005 at 13:23 UTC

    leriksen thank you for your comments. That's what I was looking for out of my post. Some indication of how others decide when to choose one tool over another.


    Hazah! I'm Employed!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://495294]
[PriNet]: i think i found the problem, the "source" array that sets the individual key values isn't being cleared, it's keeping the previous values...
[atcroft]: PriNet: You might consider posting a small, self-contained snippet of that segment of your code, and see if someone else has a better idea.....
[atcroft]: PriNet: Ahhh... interesting.
[PriNet]: small would be a problem *heh*... the program reads all the lines from a pdf and converts the individual colum data to a seperate key/value pair... that's where the "previous" array from the pdf is not being cleared properly before reading the next pdf
[atcroft]: PriNet: It was a thought....

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2017-06-28 03:16 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (620 votes). Check out past polls.