CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
XML::Simple

 



HenryL
New User

Dec 6, 2012, 12:11 PM

Post #1 of 2 (649 views)
XML::Simple Can't Post

Hi There,

I am trying to read in an XML file and check if a list ofcertain codes are contained in an element. If so I simply want to keep those records that match and discard the ones that do not match. In other words like searching for a key value on a table and only returning that set. So far I have managed to read the file and interogate the element. Then I try and write out the XML that I was reading and it seems to lose the tags of the outer elements. It is as if some of the inner elements become attributes of the outer eleemnts. I print Dumper and I can see the data. So I am wondering do I parse the data into a structure and then once I have found all the records I require write that out to an XML file? Or to a flate file? Been going up and down all day on the net and cannot seem to get the solution I need. Please help.

Thanks in Advance


rovf
Veteran

Dec 7, 2012, 8:56 AM

Post #2 of 2 (642 views)
Re: [HenryL] XML::Simple [In reply to] Can't Post

What you experience, is a consequence of XML::Simple. This is what "simple" means - simple to use, but sloppy. In particular, elements and attributes are often treated the same:

<A B="C"/>
<A><B>C</B></A>

Please read the docs - they describe this behaviour, and explain how to bypass them (there are several examples in the docs which likely will apply exactly to your problem).

If you find configuring XML::Simple too tedious, you could use one of the other XML modules. They are less "simple", but don't cause this type of confusion.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives