Home » Developer & Programmer » JDeveloper, Java & XML » Problem with XMLNS (10g 10.1.2.0.4)
Problem with XMLNS [message #378274] Mon, 29 December 2008 13:00 Go to next message
Kaeluan
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
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 #378278 is a reply to message #378274] Mon, 29 December 2008 13:28 Go to previous messageGo to next message
Michel Cadot
Messages: 60012
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Use REPLACE to add the namespace.

Regards
Michel
Re: Problem with XMLNS [message #378290 is a reply to message #378274] Mon, 29 December 2008 17:03 Go to previous message
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
Previous Topic: Importing existing projects into JDeveloper 11g
Next Topic: To get a tag value in XML
Goto Forum:
  


Current Time: Sun Dec 21 13:52:42 CST 2014

Total time taken to generate the page: 0.05506 seconds