SQL Select using Perl XPath

Discussion in 'XML' started by anthony.raj@gmail.com, Aug 3, 2005.

  1. Guest

    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, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marvin_123456

    "Memory leak" in javax.xml.xpath.XPath

    Marvin_123456, Jul 29, 2005, in forum: Java
    Replies:
    4
    Views:
    2,028
    jan V
    Jul 29, 2005
  2. Alastair Cameron
    Replies:
    1
    Views:
    7,522
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  3. Anna
    Replies:
    0
    Views:
    572
  4. Ed Garcia
    Replies:
    4
    Views:
    204
    Guinness Mann
    Aug 7, 2003
  5. palmiere
    Replies:
    1
    Views:
    466
    Erwin Moller
    Feb 9, 2004
Loading...

Share This Page