in reply to Update an XML node value based on one of the attribute values.
XML::LibXML::Element doesn't have a setData method. XML::LibXML::Text, XML::LibXML::Comment, and XML::LibXML::PI do. I think perhaps you want:
$node->firstChild->setData("blahblah");
Here's a demo:
use strict; use warnings; use XML::LibXML 2; my $doc = 'XML::LibXML'->load_xml(IO => \*DATA); foreach my $node ( $doc->findnodes('//ReferenceID') ) { $node->firstChild->setData("Reference ID type is $node->{reference +IDType}") if $node->{referenceIDType} eq 'FXDD'; } print $doc->toString; __DATA__ <root> <ReferenceID referenceIDType="FXDD">FXDDILN233</ReferenceID> </root>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Update an XML node value based on one of the attribute values.
by amitp2011 (Initiate) on Apr 18, 2014 at 09:49 UTC | |
by roboticus (Chancellor) on Apr 18, 2014 at 11:18 UTC | |
by AnomalousMonk (Archbishop) on Apr 18, 2014 at 23:41 UTC | |
by amitp2011 (Initiate) on Apr 18, 2014 at 12:15 UTC | |
by Laurent_R (Canon) on Apr 18, 2014 at 13:27 UTC | |
|
Re^2: Update an XML node value based on one of the attribute values.
by Anonymous Monk on Apr 21, 2014 at 07:23 UTC |