The Situation: i am currently using XML::LibXML to extract data from an XML. I combine this with the Xpath of the XML elements and I can read and replace most values in the XML. However, I cant seem to access a particular data in the first tag of the XML. It is a rather important field but I have tried a few ways and still cant can manipulate that field.
XML File:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<test **date_time="201111031006"** xsi:noNamespaceSchemaLocation="test.xsd">
<msg_ver>0001</msg_ver>
<sender_id>john</sender_id>
<recipient_id>mike</recipient_id>
</test>
I am trying to access the date_time field(in bold) but I cant seem to do so. I copied the XPath and tried as well and it wont work. I can actually change the field and so forth but I can't change the date_time field. I am unable to even extract the data from the field let alone change it. Using the same function i can read, extract and save changes to fields , and .
My Code
sub CHANGE_DATE()
{
my $parser = XML::LibXML->new();
my $doc = $parser->parse_file($newfile);
my $query = "/tradenet/@date_time"; ## this is the actual XPATH
my($node) = $doc->findnodes($query);
$node->setData("$date");
$doc->toFile($newfile);
Thank you in advance for time taken to look thru this..