Problem with XMLNS [message #378274] |
Mon, 29 December 2008 13:00 |
Kaeluan
Messages: 179 Registered: May 2005 Location: Montreal, Quebec
|
Senior Member |
|
|
Hello, i am trying to extract some values from an XML i am receiving from an external provider. I have a problem getting my result.
Here is my code to read the values from XML
SELECT EXTRACTVALUE(VALUE(t), '/Location/Latitude') xmlns_val
FROM
TABLE(XMLSEQUENCE(EXTRACT(XMLTYPE('<?xml version="1.0" encoding="utf-8" ?>
<Location xmlns="http://www.serviceprovider.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Latitude>43.914979</Latitude>
<Longitude>-78.584694</Longitude>
<PostalCode>L1B1M4</PostalCode>
</Location>'),
'/Location'))) t
Actually this select return nothing but if i change the first occurence of xmlns (xmlns="http://www.serviceprovider.com/") for something like xmlns:test="http://www.serviceprovider.com/" it work correctly. Is this an error with the XML i am receiving or is Oracle have some problem when Namespace is not specified. From what i know it should not be mandatory to have a namespace specified.
Any hint about how to solve my problem will be appreciated
Thank
|
|
|
|
Re: Problem with XMLNS [message #378290 is a reply to message #378274] |
Mon, 29 December 2008 17:03 |
mchadder
Messages: 224 Registered: May 2005 Location: UK
|
Senior Member |
|
|
Hi,
This is really due to the fact that, in the example you have given us, the xpath you have defined needs to be namespace aware, and the way to do that in Oracle using both the EXTRACT and EXTRACTVALUE functions is via the third parameter to these functions which allows specification of a namespace.
For more information, see here
Regards
|
|
|