Wednesday, May 07, 2008

LPX-00601: Invalid token in 'XPath expression'

Always check out the original article at for latest comments, fixes and updates.

You can get this error while attempting to extract nodes containing a namespace prefix using a SQL expression like the following:

select extractValue(
'//openSearch:totalResults') val
from xml_documents
where id = 38;

ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00601: Invalid token in: '//openSearch:totalResults'
The problem is caused by the missing namespace parameter in the function call:

select extractValue(
'xmlns:openSearch=""') val
from xml_documents
where id = 38;

Clearly the namespace declaration in green, must match the corresponding string in the source XML document.
Note also that Oracle uses double quotes to enclose the string whereas single or double quotes might be used in the source document indifferently, what really matters is the string delimited by the quotes and do not forget that is case sensitive: a mismatching string will cause a null value to be returned instead of the expected node.

See a previous posting on problems related to default namespaces declarations and Oracle XML functions.


Anonymous said...


This is my xml snippet


I need to extract the value of the tag. Since it has no pre defined name space I am unable to extract it

I tried the below query

extract(emp_payload, '//OrderResponse/BuyersID/text()', 'xmlns="')aa
from emp_messagequeue.

I am getting a null output

Can some one help me?

Byte64 said...

unfortunately the xml snippet doesn't show up because you didn't escape the xml tags, you need to escape angle brackets with their escaped counterpart or replace with square brackets.
Try again.


yes you can!

Two great ways to help us out with a minimal effort. Click on the Google Plus +1 button above or...
We appreciate your support!

latest articles