Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 100

Working with XMLTABLE, problem extracting data where elements have no prefixes/namespaces - forum topic by mikemadrinan

$
0
0

I am working on an XML parsing requirement using XML Table.  I am running into a problem with data from elements with no namespaces or prefixes.  Extraction using XMLTable doesn't seem to work.  Extraction from elements with prefixes seem to work normally.  Say I have an XML below (not actual as I am working with sensitive data):

<pfx:MAIN xlmns:pfx="http://www.google.com/">
  <pfx:header>
    <pfx:name>sample</pfx:name>
    <pfx:value>1</pfx:value>
  </pfx:header>
  <pfx:payload>
    <portfolio>
      <portfolioname>A</portfolioname>
      <portfoliovalue>100</portfoliovalue>
    </portfolio>
  </pfx:payload>
</pfx:MAIN xlmns:pfx="http://www.google.com/">

Running XML using the below SQL query returns pfx:name and pfx:value normally but returns null for portfolioname and portfolio value.  

SELECT PORTFOLIO.*
FROM  (SELECT * FROM XML_TABLE WHERE xml_ID = 1) AS XML_ROW,
        XMLTable(
	  XMLNAMESPACES('http://www.google.com' AS "X"),
	  '/' PASSING XML_ROW.XML_DATA
	  COLUMNS
	     "name" VARCHAR(100) PATH 'X:MAIN/X:header/X:name'
	    ,"value" VARCHAR(100) PATH 'X:MAIN/X:header/X:value'
	    ,"portfolioname" VARCHAR(100) PATH 'X:MAIN/X:payload/portfolioname'
	    ,"portfoliovalue" VARCHAR(100) PATH 'X:MAIN/X:payload/portfoliovalue'
 	) AS PORTFOLIO

Like I said, the sample XML and query is not the actual one I am running so there may not be any problems on the above but if anyone who has encountered something similar before has inputs or tips on what to check, it will be very helpful.  Thanks!
 

Forums: 

Viewing all articles
Browse latest Browse all 100

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>