Skip to Main Content
  • Questions
  • How to extract the tag value form the xml tag with colon


Question and Answer

Chris Saxon

Thanks for the question.

Asked: November 15, 2023 - 6:01 am UTC

Last updated: November 21, 2023 - 10:59 am UTC

Version: 19c

Viewed 1000+ times

You Asked

How to Extract the Tag value from xml which as tag name with colon.

    <description>AUD/JPY representative rate as at 4.00 pm Eastern Australian time on 14 Nov 2023</description>
    <cb:statistics rdf:parseType="Resource">
      <rdf:type rdf:resource=""/>
      <cb:exchangeRate rdf:parseType="Resource">
        <rdf:type rdf:resource=""/>
        <cb:observation rdf:parseType="Resource">
          <rdf:type rdf:resource=""/>
        <cb:rateType>4.00 pm foreign exchange rates</cb:rateType>
        <cb:observationPeriod rdf:parseType="Resource">
          <rdf:type rdf:resource=""/>

Tried with by inserting the xml as clob object.
   test_clob t;

Getting dORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00601: Invalid token in: ' '/rdf:RDF/item/cb:statistics/cb:exchangeRate/cb:baseCurrency/text()'
31011. 00000 -  "XML parsing failed"
*Cause:    XML parser returned an error while trying to parse the document.
*Action:   Check if the document to be parsed is valid.

Please suggest.

and Chris said...

I tried the suggested action:

Action: Check if the document to be parsed is valid.

And indeed, the XML shown is invalid!

- There's no root element
- Many of the elements have prefixes with undefined namespaces (e.g. the "dc" in dc:date).

If this is only part of the document you're working with, please provide a complete, valid document. Then we can help further.

If this is the complete XML document you've received, the first step is to work with them to get a valid document.


  (1 rating)

More to Explore


The Oracle documentation contains a complete SQL reference.