473,382 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

SQL Select using Perl XPath

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

Aug 3 '05 #1
0 1238

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Yang | last post by:
Hi everyone: after I parse a .xml file, I still have the xml tags in my varibles. Please help. Why my $title varible is " <title>title is here</title>" instead of "title is here"??? thanks...
3
by: Kathy Burke | last post by:
Hi again, I'm using the following xpath (works in visualizer) with a SelectSingleNode("xpath") statement. //Station/(WI])]/@order Problem is I get an error "expression passed to this method...
2
by: Alistair Bayley | last post by:
(.Net framework version 1.1.4322) The following XSL test case is rejected by System.Xml.Xsl.XslTransform, with an XsltException: "($dummy)+0 is an invalid XPath expression." If you remove the...
2
by: Trillium | last post by:
This seems like it should be really easy, but I cannot seem to make it work. I am trying to retrieve the text value of an element named "child2Element" from an XML file in a .NET (v 1.1) with an...
6
by: Paul J Lay | last post by:
I am using the XmlDocument Select Nodes method and it seems to work OK except that it returns embedded nodes in the collection when I only want the nodes that are not embedded. For example I have...
6
by: Vinit | last post by:
Hi I am passing an arraylist to a c#/.net webmethod from a perl client using soap:lite. The trace shows the elements in the xml request. The arraylist input in the webmethod however does not...
8
by: sehiser | last post by:
Hello, I've been reading up on xpath and I am able to access elements with it. I haven't been able to figure one thing out though. How would I use XPath to select an element where the text...
4
by: Pranjal9880 | last post by:
Hi all I am trying to parse the xml file using perl in which I am succeeded , I am able to fetch the data from the xml file by using one keyword. Now I want to do it using more than one keyword. It...
4
by: paragpdoke | last post by:
Hello Perl Experts. I am new to perl and seek help with some XML stuff. My XML document is nested a few levels deep...so I want to use xpath to find the exact element to work with. Then I wish to:...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.