in reply to Re: Update an XML node value based on one of the attribute values.
in thread Update an XML node value based on one of the attribute values.

But where are we setting the value of node ReferenceID.
  • Comment on Re^2: Update an XML node value based on one of the attribute values.

Replies are listed 'Best First'.
Re^3: Update an XML node value based on one of the attribute values.
by roboticus (Chancellor) on Apr 18, 2014 at 11:18 UTC

    amitp2011:

    He's not setting it--tobyink was simply showing you how to get the desired element that has the setData method. Frequently, when answering questions, we show you how to get past the stumbling point, we figure you can take it from there. ;^)

    By the way, if you would, please edit your first post in this thread and remove the blank from the closing </Code> tag.change the code tags from <Code> to <code>, so the code displays correctly. (Don't forget to change the closing tag, too!)

    Update: ambrus pointed out that the problem in the original post was that the problem wasn't the case, but that there was an extra blank in the closing tag.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

      amitp2011 also appears to be using the  &lt; entity rather than a literal  '<' to begin the  <code> tag — or is the presence of this entity in the viewed source a rendering artifact?

      For the code from tobyink
      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;

      when i use $node ->setData("xyz"); i again get the same error. Please excuse my ignorance, i am very new to perl scripting.
        Your closing code tag should be </code>, not <code>. Please check your posts in the preview page before posting for real. And, please also insert code tags in your original post.