I hav开发者_JS百科e an XML file, with some format. I want the data to be modified in some way I want. I feel XML::Twig is the way to do it.
I want to know if there is any other better alternative?
You will probably find the XML::Twig
is an ideal tool for the task and there have been plenty of questions/answers on Stack Overflow that seem to reaffirm this:
- In Perl, how can I change an element in an XML file without changing the format of the XML file?
- Can you provide an example of parsing HTML with your favorite parser?
- How can I extract some XML data from a URL using XML::Twig?
- How can I add an attribute to a child element using Perl’s XML::Twig?
- How can I get content using XML::Twig?
- How do I add child elements to XML using Perl’s XML::Twig?
You may also find it helpful to know that the author of XML::Twig does answer questions on this site: Mirod.
However if you really are looking for an alternative then have a look at XML::LibXML
. This module is based on libxml2 library (XML::Twig is written on top of XML::Parser
which uses the expat library).
Mirod himself lists alternatives to XML::Twig in his FAQ.
精彩评论