Xpath expression failing...

Discussion in 'XML' started by Mapper99, Feb 12, 2008.

  1. Mapper99

    Mapper99 Guest

    I have some simple xml:

    <users>
    <title>Floor1</title>
    <user>
    <fullname>John Doe</fullname>
    <ID>Binary Avenue 1234 FL</ID>
    <email></email>
    <lat>2</lat>
    <lon>4</lon>
    </user>
    </users>

    I am trying to retrieve the value of "lat" where "fullname=John Doe"
    using this PHP based xpath expression:

    $lat = $users->xpath('/users/user/[fullname="Janet Smith"]');

    Apparently my expression is invalid.

    Any ideas?

    QF
     
    Mapper99, Feb 12, 2008
    #1
    1. Advertising

  2. Mapper99 a écrit :
    > I have some simple xml:
    >
    > <users>
    > <title>Floor1</title>
    > <user>
    > <fullname>John Doe</fullname>
    > <ID>Binary Avenue 1234 FL</ID>
    > <email></email>
    > <lat>2</lat>
    > <lon>4</lon>
    > </user>
    > </users>
    >
    > I am trying to retrieve the value of "lat" where "fullname=John Doe"
    > using this PHP based xpath expression:
    >
    > $lat = $users->xpath('/users/user/[fullname="Janet Smith"]');

    ^^

    >
    > Apparently my expression is invalid.
    >
    > Any ideas?


    'string(/users/user[fullname="Janet Smith"]/lat)'

    >
    > QF



    --
    Cordialement,

    ///
    (. .)
    --------ooO--(_)--Ooo--------
    | Philippe Poulard |
    -----------------------------
    http://reflex.gforge.inria.fr/
    Have the RefleX !
     
    Philippe Poulard, Feb 12, 2008
    #2
    1. Advertising

  3. Mapper99 wrote:
    > I have some simple xml:
    >
    > <users>
    > <title>Floor1</title>
    > <user>
    > <fullname>John Doe</fullname>
    > <ID>Binary Avenue 1234 FL</ID>
    > <email></email>
    > <lat>2</lat>
    > <lon>4</lon>
    > </user>
    > </users>
    >
    > I am trying to retrieve the value of "lat" where "fullname=John Doe"
    > using this PHP based xpath expression:
    >
    > $lat = $users->xpath('/users/user/[fullname="Janet Smith"]');


    /users/user[fullname = "John Doe"]/lat


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Feb 12, 2008
    #3
  4. Mapper99

    Mapper99 Guest

    On Feb 12, 9:47 am, Martin Honnen <> wrote:
    > Mapper99 wrote:
    > > I have some simple xml:

    >
    > > <users>
    > > <title>Floor1</title>
    > >   <user>
    > >   <fullname>John Doe</fullname>
    > >   <ID>Binary Avenue 1234 FL</ID>
    > >   <email></email>
    > >   <lat>2</lat>
    > >   <lon>4</lon>
    > >   </user>
    > > </users>

    >
    > > I am trying to retrieve the value of "lat" where "fullname=John Doe"
    > > using this PHP based xpath expression:

    >
    > > $lat = $users->xpath('/users/user/[fullname="Janet Smith"]');

    >
    >    /users/user[fullname = "John Doe"]/lat
    >
    > --
    >
    >         Martin Honnen
    >        http://JavaScript.FAQTs.com/- Hide quoted text -
    >
    > - Show quoted text -


    Have changed my code to:

    $lats = $users->xpath('/users/user/[fullname="Janet Smith"]/lat');

    I am still receiving an invalid expression error.

    Mark
     
    Mapper99, Feb 12, 2008
    #4
  5. Mapper99 wrote:
    > On Feb 12, 9:47 am, Martin Honnen <> wrote:


    >> /users/user[fullname = "John Doe"]/lat

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    > Have changed my code to:
    >
    > $lats = $users->xpath('/users/user/[fullname="Janet Smith"]/lat');

    ^^^
    >
    > I am still receiving an invalid expression error.


    Well if you don't use what is posted but insist on injecting your own
    errors again we can't help. A predicate is part of a step and not a new
    step so remove that / before the square bracket.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Feb 12, 2008
    #5
  6. Mapper99

    Mapper99 Guest

    On Feb 12, 10:12 am, Martin Honnen <> wrote:
    > Mapper99 wrote:
    > > On Feb 12, 9:47 am, Martin Honnen <> wrote:
    > >>    /users/user[fullname = "John Doe"]/lat

    >
    >        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    >
    > > Have changed my code to:

    >
    > > $lats = $users->xpath('/users/user/[fullname="Janet Smith"]/lat');

    >
    >                                      ^^^
    >
    >
    >
    > > I am still receiving an invalid expression error.

    >
    > Well if you don't use what is posted but insist on injecting your own
    > errors again we can't help. A predicate is part of a step and not a new
    > step so remove that / before the square bracket.
    >
    > --
    >
    >         Martin Honnen
    >        http://JavaScript.FAQTs.com/


    Well said Martin. My apologies.

    QF
     
    Mapper99, Feb 12, 2008
    #6
  7. Mapper99

    Mapper99 Guest

    On Feb 12, 10:38 am, Mapper99 <> wrote:
    > On Feb 12, 10:12 am, Martin Honnen <> wrote:
    >
    >
    >
    >
    >
    > > Mapper99 wrote:
    > > > On Feb 12, 9:47 am, Martin Honnen <> wrote:
    > > >>    /users/user[fullname = "John Doe"]/lat

    >
    > >        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    >
    > > > Have changed my code to:

    >
    > > > $lats = $users->xpath('/users/user/[fullname="Janet Smith"]/lat');

    >
    > >                                      ^^^

    >
    > > > I am still receiving an invalid expression error.

    >
    > > Well if you don't use what is posted but insist on injecting your own
    > > errors again we can't help. A predicate is part of a step and not a new
    > > step so remove that / before the square bracket.

    >
    > > --

    >
    > >         Martin Honnen
    > >        http://JavaScript.FAQTs.com/

    >
    > Well said Martin.  My apologies.
    >
    > QF- Hide quoted text -
    >
    > - Show quoted text -


    Is this also an acceptable Xpath statement?

    $lats = $users->xpath('/users/user[fullname=$fullname]/lat');

    QF
     
    Mapper99, Feb 12, 2008
    #7
  8. Mapper99

    Joe Fawcett Guest

    "Mapper99" <> wrote in message
    news:...
    On Feb 12, 10:38 am, Mapper99 <> wrote:
    > On Feb 12, 10:12 am, Martin Honnen <> wrote:
    >
    >
    >
    >
    >
    > > Mapper99 wrote:
    > > > On Feb 12, 9:47 am, Martin Honnen <> wrote:
    > > >> /users/user[fullname = "John Doe"]/lat

    >
    > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    >
    > > > Have changed my code to:

    >
    > > > $lats = $users->xpath('/users/user/[fullname="Janet Smith"]/lat');

    >
    > > ^^^

    >
    > > > I am still receiving an invalid expression error.

    >
    > > Well if you don't use what is posted but insist on injecting your own
    > > errors again we can't help. A predicate is part of a step and not a new
    > > step so remove that / before the square bracket.

    >
    > > --

    >
    > > Martin Honnen
    > > http://JavaScript.FAQTs.com/

    >
    > Well said Martin. My apologies.
    >
    > QF- Hide quoted text -
    >
    > - Show quoted text -


    Is this also an acceptable Xpath statement?

    $lats = $users->xpath('/users/user[fullname=$fullname]/lat');

    QF

    Yes, providing $fullname is in scope.

    --

    Joe

    http://joe.fawcett.anme
     
    Joe Fawcett, Feb 13, 2008
    #8
    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:
    1,974
    jan V
    Jul 29, 2005
  2. Alastair Cameron
    Replies:
    1
    Views:
    7,414
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  3. Anna
    Replies:
    0
    Views:
    523
  4. goog
    Replies:
    0
    Views:
    508
  5. GIMME
    Replies:
    3
    Views:
    11,969
    vforvikash
    Dec 29, 2008
Loading...

Share This Page