Extracting values from the XML string [message #563299] |
Sat, 11 August 2012 14:53 |
|
Rithy03
Messages: 1 Registered: August 2012 Location: Ashburn
|
Junior Member |
|
|
Hi,
I would like to extract only the values from the XML string
The xml string looks like
<addressId>1</addressId><addressSource xsi:nil="true"/><addressInfoName xsi:nil="true"/><addressLine1>245 Murray Ln SW Bldg 14</addressLine1><addressLine2 xsi:nil="true"/><addressLine3 xsi:nil="true"/><addressLine4 xsi:nil="true"/><phoneNumber xsi:nil="true"/><phoneNumberExt xsi:nil="true"/><city>Washington</city><county xsi:nil="true"/><stateOrProvince>DC</stateOrProvince><ZIPCode>20528-1002</ZIPCode><country>USA</country><congressionalDistrict xsi:nil="true"/></address>
And the expected output is
245 Murray Ln SW Bldg 14
Washington
DC
20528-1002
USA
I need to extract only the values from the XMl string using sql
Could anyone please help
|
|
|
|
Re: Extracting values from the XML string [message #563302 is a reply to message #563299] |
Sat, 11 August 2012 17:18 |
Solomon Yakobson
Messages: 3303 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
Rithy03 wrote on Sat, 11 August 2012 15:53The xml string looks like
It doesn't look like a well-formed XML:
SQL> select xmltype('
2 <addressId>1</addressId>
3 <addressSource xsi:nil="true"/>
4 <addressInfoName xsi:nil="true"/>
5 <addressLine1>245 Murray Ln SW Bldg 14</addressLine1>
6 <addressLine2 xsi:nil="true"/>
7 <addressLine3 xsi:nil="true"/>
8 <addressLine4 xsi:nil="true"/>
9 <phoneNumber xsi:nil="true"/>
10 <phoneNumberExt xsi:nil="true"/>
11 <city>Washington</city>
12 <county xsi:nil="true"/>
13 <stateOrProvince>DC</stateOrProvince>
14 <ZIPCode>20528-1002</ZIPCode>
15 <country>USA</country>
16 <congressionalDistrict xsi:nil="true"/>
17 </address>'
18 ) from dual
19 /
ERROR:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00245: extra data after end of document
Error at line 3
ORA-06512: at "SYS.XMLTYPE", line 301
ORA-06512: at line 1
no rows selected
SQL>
It has end tag </address> but no <address> tag. It references namespace XSI:NIL without declaring it and possibly has more issues.
SY.
[Updated on: Sat, 11 August 2012 17:19] Report message to a moderator
|
|
|
|
|