#!/usr/bin/perl use strict; use warnings; use XML::LibXML; use XML::LibXML::XPathContext; my $file = "./incident.xml"; my $parser = XML::LibXML->new(XML_LIBXML_RECOVER => 2); $parser->recover_silently(1); my $dom = $parser->load_xml( location => $file ); my $root = $dom->getDocumentElement(); my $xpc = XML::LibXML::XPathContext->new($root); ############################################## # If we have an incident ticket reference get info from that ticket. my $inc_node = $xpc->findnodes('/upload/incident[number/text() = "INC902531"]'); my $service_restoration_time = $xpc->findvalue( "./u_service_restoration_time", $inc_node ); my $assignment_group = $xpc->findvalue( ".//assignment_group/\@display_value", $inc_node ); # etc... print $service_restoration_time . "\n" ; print $assignment_group . "\n" ; #### 2009-12-15 14:29:55 2009-12-21 05:00:21 none 1970-01-03 05:30:05 none INC902550 2009-12-15 23:01:17 Service Restored 2009-12-15 14:29:55 Software Issue/Bug 92becbd70a0a140b0187537b8516f18c