in reply to Edit XML File in perl

CPAN search: XML

Some that I've used are XML::Simple, XML::Smart, XML::LibXML, XML::Twig. They all have their pros & cons; your best bet is to read the docs, pick a couple that look best suited to your needs, and give them a try.

Replies are listed 'Best First'.
Re^2: Edit XML File in perl
by py_201 (Acolyte) on Dec 08, 2009 at 05:24 UTC
    Thanks for your response.
    But what you have mentioned are Xml parsers (used to read a parser).
    But i need to edit a XML file. I dont want to read it using a parser and write it to some other file using a XML writer. as that would certaily take time.
    Do we have XML editors like i would read a XML and at a particular point add or remove the required tags.
      These can do that. For example:
      #!/usr/bin/perl use strict; use warnings; use XML::Smart; my $xmlstring = q{ <root> <member id="1" name="member1"> <ips> <ip1> <from></from> <to></to> </ip1> <ip2> <from></from> <to></to> </ip2> </ips> </member> </root>}; my $XML = XML::Smart->new($xmlstring); $XML->{root}{member}{ips}{ip1}{from} = 'I am IPS IP1 From'; print $XML->data(noheader => 1); __END__ <root> <member id="1" name="member1"> <ips> <ip1> <from>I am IPS IP1 From</from> <to/> </ip1> <ip2> <from/> <to/> </ip2> </ips> </member> </root>