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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Manipulating XML and emitting the modified XML



Feb 16, 2018, 9:01 AM

Post #1 of 3 (4323 views)
Manipulating XML and emitting the modified XML Can't Post

Hi all
I need to parse xml pieces. In most cases I may need to change the value of an attribute or two and then emit the modified XML. The XML::Simple with the XMLin and XMLout seemed to be the best solution. But...
I have a new requirement. Let'e consider this structure:


what I need is to traverse on that tree and gather the values of, let's say, attribute3, attribute4, attribute7 and based on their values decide whether to retain that specific criterion or chop it away. And when done, emit the modified xml.
1. What would be the best module to do all the above?
2. How should I approach it?

Thank you


Feb 25, 2018, 8:49 PM

Post #2 of 3 (4230 views)
Re: [zatlas1] Manipulating XML and emitting the modified XML [In reply to] Can't Post


There are various tools for parsing XML, it usually comes down to a matter of preference. My preference is nearly always XML::LibXML. Though I commonly see XML::Twig recommended.

You haven't provided enough detail to provide you with a valuable approach, but this will come once you understand how to use the tool of your choice. Learn how to use it to parse XML, modify XML, then write XML.



Veteran / Moderator

Feb 25, 2018, 11:23 PM

Post #3 of 3 (4227 views)
Re: [zatlas1] Manipulating XML and emitting the modified XML [In reply to] Can't Post

Please note that XML::Simple is deprecated and should probably not be used, at least not for new projects.

Even the documentation of the module states it explicitly:

You really don't want to use this module in new code.

So don't use it, that will save you quite a bit of pain.

I recommend that you use one of the two modules suggested by Chris.


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

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