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: Update an XML node value based on one of the attribute values.: Edit Log

New User

Apr 17, 2014, 10:39 PM

Views: 11674
Update an XML node value based on one of the attribute values.

I have to update the value of a node by based on the value of one of its attributes.

<ReferenceID referenceIDType="FXDD">FXDDILN233</ReferenceID>
For the above Tag.
i want to edit the value FXDDILN233 based on the attribute value referenceIDType="FXDD"

I tried the below code:

my $nodeset = $doc->findnodes("//*[name()='ReferenceID']"); 
foreach my $node ($nodeset->get_nodelist) {
if ($node->hasAttribute("referenceIDType") == XML::LibXML::Boolean->True) {
$RetVal = $node->getAttributeNode("referenceIDType")->getValue();
if ($RetVal eq "FXDD") {
print "Attribute VAL=@@@@@@@@@@@@"."$RetVal \n";


But getting error on the setData line.. 
Whats is it that could be wrong ?
Thanks in advance.

(This post was edited by amitp2011 on Apr 17, 2014, 11:18 PM)

Edit Log:
Post edited by amitp2011 (New User) on Apr 17, 2014, 11:18 PM

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

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