Plankton has asked for the wisdom of the Perl Monks concerning the following question:
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 $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 ... }
... and ...my $path = '//cidr-map[@name]='; $path .= "\"$node_name\"; $xp->setNodeText( $path, $ips_as_string );
... the xml looks like this ...my $path = '//cidr-map/cidr-map-to[@name]='; $path .= "\"$node_name\"; $xp->setNodeText( $path, $ips_as_string );
.. 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!... <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> ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trouble using setNodeText()
by wind (Priest) on Apr 06, 2011 at 20:15 UTC | |
|
Re: Trouble using setNodeText()
by Anonymous Monk on Apr 06, 2011 at 21:00 UTC |