Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ExtractValue and array tags??

Keith JamiesonJul 14 2008 — edited Jul 16 2008
Database: 11.1.0.6.0

Below is a sample of an XML file. I have this loaded as an xmltype column in a table called mytable1.
<?xml version="1.0" encoding="UTF-8"?>
<ApplicationProfile UniqueID="KWID_AP" xmlns="http://namespaces.globalplatform.org/systems-profiles/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://namespaces.globalplatform.org/systems-profiles/1.1.0 GP.systems.profiles.1.1.0.ApplicationProfile.xsd" ProfileVersion="1.1.0">
	<Description>MyDescription</Description>
	<DataElement Name="AdminPinMinLength" External="true" Update="false" ReadWrite="false" FixedLength="true" Length="1" Type="ByteString" Encoding="HEX"/>
	<DataElement Name="AdminPinMaxLength" External="true" Update="false" ReadWrite="false" FixedLength="true" Length="1" Type="ByteString" Encoding="HEX"/>
</ApplicationProfile>
Now I can read Description quite easily using
SELECT extractvalue(xml_column, '/ApplicationProfile/Description','xmlns="http://namespaces.globalplatform.org/systems-profiles/1.1.0"')
  FROM mytable1;
However, where I am really struggling is reading the individual DataElements.
As I understand it, using extractvalue can only return a scalar (ie only one value can be returned).

If I use
  SELECT extractvalue(xml_column, 'ApplicationProfile/DataElement','xmlns="http://namespaces.globalplatform.org/systems-profiles/1.1.0"')
  FROM mytable1;
I get ORA19025. ExtractValue returns value of only one Node.

So, as I understand it, I need to specify which element number and value I need to get.

Below is one of the numerous examples I have tried which returns Null.
  SELECT extractvalue(xml_column, 'ApplicationProfile/DataElement/Name[1]','xmlns="http://namespaces.globalplatform.org/systems-profiles/1.1.0"')
  FROM mytable1;
How can I extract an individual array element, preferable using extractvalue but an example of using xquery would be useful too?



And to extend this a bit further, what I'm hoping to achieve is to be able to add/remove dataelements (along with their attributes).

eg I may want to add/modify values/or remove dataelements via sql.
	<DataElement Name="AdminPinValue" External="true" Update="false" ReadWrite="false" Type="ByteString" Encoding="ASCII"/>
to the above xml (within the DB).

Is this possible and if so how?

Added database version
Message was edited by:
Keith Jamieson
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 13 2008
Added on Jul 14 2008
10 comments
2,708 views