Home » Developer & Programmer » JDeveloper, Java & XML » Problem with XMLNS (10g
Problem with XMLNS [message #378274] Mon, 29 December 2008 13:00 Go to next message
Messages: 178
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
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">
                          '/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

Re: Problem with XMLNS [message #378278 is a reply to message #378274] Mon, 29 December 2008 13:28 Go to previous messageGo to next message
Michel Cadot
Messages: 62217
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Use REPLACE to add the namespace.

Re: Problem with XMLNS [message #378290 is a reply to message #378274] Mon, 29 December 2008 17:03 Go to previous message
Messages: 224
Registered: May 2005
Location: UK
Senior Member

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

Previous Topic: Importing existing projects into JDeveloper 11g
Next Topic: To get a tag value in XML
Goto Forum:

Current Time: Fri Nov 27 06:08:14 CST 2015

Total time taken to generate the page: 0.06165 seconds