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!