Dear wise monks ... I pull out a couple of lists if ip address from my XML data
my $xp = XML::XPath->new(xml => $fpdomaininfo ); my $nodeset = $xp->find('//cidr-map'); foreach my $node ($nodeset->get_nodelist) { my $node_name = $node->findvalue ( '@name' ) -> stri +ng_value; my $ips_as_string = $node->string_value; ... make changes to ips_as_string ... }
Then I make changes to these list, then I want to put the data back into my xml data, but I cannot figure out what path I am suppose to use in the setNodeText call. I have tried this like ...
my $path = '//cidr-map[@name]='; $path .= "\"$node_name\"; $xp->setNodeText( $path, $ips_as_string );
... and ...
my $path = '//cidr-map/cidr-map-to[@name]='; $path .= "\"$node_name\"; $xp->setNodeText( $path, $ips_as_string );
... the xml looks like this ...
... <cidr-map name="Internal test" default-datacenter="Default Datacenter" +> <cidr-map-to name="AKA Edge"> <blocks>127.0.241.174 127.0.0.181</blocks> </cidr-map-to> </cidr-map> <cidr-map name="Prod Internal Actual" default-datacenter="Default Data +center"> <cidr-map-to name="AKA Edge"> <blocks>127.0.12.1 10.0.0.1 198.168.1.1</blocks> </cidr-map-to> </cidr-map> ...
.. and other ham fist-ed attempts while I grasp at straws. I cannot figure out for the life me what $path I should use in the setNodeText call. Can you all help? Thanks!

In reply to Trouble using setNodeText() by Plankton

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.