SQL Select using Perl XPath

A

anthony.raj

Hi,

I have an XML Datasource in the following format -

<?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?>
<table>
<event >
<field name="user" value="anthony"/>
<field name="date" value="2005-08-5"/>
</event>
<event>
<field name="user" value="anthony"/>
<field name="date" value="2005-08-5"/>
</event>
........
</table>

I require to search for the following fields - user & date (act as
filters).

Following is the code to handle the same -
use XML::XPath;
use XML::XPath::XMLParser;

my $filename = 'data.xml';
my $pathn =
'/table/event/field/[@name="user"][@value="anthony"]|[@name="date"][@value="2005-08-06"]';

my $xp = XML::XPath->new(filename => $filename);
my $nodeset = $xp->find($pathn);

foreach my $node ($nodeset->get_nodelist) {

print XML::XPath::XMLParser::as_string($node),"\n\n";

}

Could someone guide me about details on union operators
or SQL's AND approach .

Goal -
Require to select data based on user='anthony' and date = '2005-08-05'

TIA,
Antonio
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top