Thursday, 15 August 2013

xml - Extract/extractValue for tags with a namespace -



xml - Extract/extractValue for tags with a namespace -

i trying extract value of tag name space in oracle 10g. query is

select extract(xmltype(xml_text), '/feed/entry[1]/yt:statistics', 'xmlns:yt="http://gdata.youtube.com/schemas/2007"') title edgecast_xml load_date > sysdate-1

and returns null

the original xml (i had label htp opposed http avoid links):

<feed xmlns='htp://www.w3.org/2005/atom' xmlns:media='htp://search.yahoo.com/mrss/' xmlns:opensearch='htp://a9.com/-/spec/opensearch/1.1/' xmlns:gd='htp://schemas.google.com/g/2005' xmlns:yt='http://gdata.youtube.com/schemas/2007' gd:etag='w/&quot;d0yeqh88esp7i2a9xrzqeu8.&quot;'> <entry gd:etag='w/&quot;cumnrh47ecp7i2a9xrzrguo.&quot;'> <id>tag:youtube.com,2008:video:qxptxpjlnjy</id> <updated>2014-06-17t02:51:35.000z</updated> <category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/> <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='nonprofit' label='nonprofits &amp; activism'/> <title>rear admiral lee addresses restrictive regulations on religious liberty</title> <gd:rating average='4.8343196' max='5' min='1' numraters='5239' rel='http://schemas.google.com/g/2005#overall'/> <yt:statistics favoritecount='0' viewcount='365565'/> <yt:rating numdislikes='217' numlikes='5022'/> </entry> </feed>

why getting null? if select /feed/entry[1] returns xml within entry tag.

since getting result when utilize /feed/entry[1] seems default (atom) namespace automatically registered. yt namespace registered well, should work.

you null when extract string value of /feed/entry[1]/yt:statistics because <yt:statistics> element has no text content. it's empty tag. can read attributes:

/feed/entry[1]/yt:statistics/@viewcount

and

/feed/entry[1]/yt:statistics/@favoritecount

xml oracle plsql extract extract-value

No comments:

Post a Comment