Xpath expression failing...

M

Mapper99

I have some simple xml:

<users>
<title>Floor1</title>
<user>
<fullname>John Doe</fullname>
<ID>Binary Avenue 1234 FL</ID>
<email>[email protected]</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
 
P

Philippe Poulard

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 protected]</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)'


--
Cordialement,

///
(. .)
--------ooO--(_)--Ooo--------
| Philippe Poulard |
-----------------------------
http://reflex.gforge.inria.fr/
Have the RefleX !
 
M

Martin Honnen

Mapper99 said:
I have some simple xml:

<users>
<title>Floor1</title>
<user>
<fullname>John Doe</fullname>
<ID>Binary Avenue 1234 FL</ID>
<email>[email protected]</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
 
M

Mapper99

Mapper99 said:
I have some simple xml:
<users>
<title>Floor1</title>
  <user>
  <fullname>John Doe</fullname>
  <ID>Binary Avenue 1234 FL</ID>
  <email>[email protected]</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
 
M

Martin Honnen

Mapper99 said:
/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.
 
M

Mapper99

Mapper99 said:
   /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.

Well said Martin. My apologies.

QF
 
M

Mapper99

Mapper99 said:
   /users/user[fullname = "John Doe"]/lat
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Have changed my code to:
$lats = $users->xpath('/users/user/[fullname="Janet Smith"]/lat');
                                     ^^^
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
 
J

Joe Fawcett

Mapper99 said:
/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.
 

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,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top