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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top