I have a chunk of xml code with a bunch of elements in it. I need to replace some of the data in the xml with some other values. I can make XML::Simple do this, but it mangles the order. I am now trying to get XML::LibXML to work, but I am having a great deal of trouble.
The part of the xml I am wanting to change looks like this:
<remote name="korg">
I need to be able to change the 'korg' value to something else without totally making a hash out of the document.
What I have tried looks like:
my $parser = XML::LibXML->new(); my $doc = $parser->parse_file($filename); my $root = $doc->getDocumentElement; print $doc->toString; my $query1 = '//remote[@name="korg"]/'; my ($node1) = $doc->findnodes($query1); $node1->setData('other');
This was pulled from a XML::LibXML sample. unfortunatly the sample errors out saying it cannot find the function setData in XML::LibXML::Element.
Any ideas how to make this work? I am not a total Perl newbie, but I am a total XPath newbie.
Thanks!
In reply to How do I get LibXML to replace attribute values? by alanpdx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |