xml - Extracting part of XMLType in PL/SQL because of repeating node inside another repeating mode -



have xmltype object , want extract opening times table.

<workspace>   <title>workspace1</title>   <item>     <day>1</day>     <openingtime>8:00</openingtime>     <closingtime>12:00</closingtime>   </item>   <item>     <day>1</day>     <openingtime>13:00</openingtime>     <closingtime>18:00</closingtime>   </item> <workspace> <workspace>   <title>workspace2</title>   <item>     <day>1</day>     <openingtime>9:00</openingtime>     <closingtime>14:00</closingtime>   </item>   <item>     <day>3</day>     <openingtime>12:00</openingtime>     <closingtime>16:00</closingtime>   </item> <workspace> 

i use like:

select extractvalue(value(p),'workspace/item/day/text()') day       ,extractvalue(value(p),'workspace/item/openingtime/text()') open       ,extractvalue(value(p),'workspace/item/closingtime/text()') close       table (xmlsequence(extract(y,'workspace'))) p       extractvalue(value(p),'/workspace/title/text()') 'workspace1'; 

where y xmltype above. won't work, because still find more 1 item node. need extract element values title workspace2 (values 1, 9:00, 14:00, 3, 12:00, 16:00). if extract not value, whole part of xmltype. ideas?
thanks, michal

with @thinkjet tricks query may this

with x (   select      xmltype('        <workplaces>              <workspace>           <title>workspace1</title>           <item>             <day>1</day>             <openingtime>8:00</openingtime>             <closingtime>12:00</closingtime>           </item>           <item>             <day>1</day>             <openingtime>13:00</openingtime>             <closingtime>18:00</closingtime>           </item>         </workspace>         <workspace>           <title>workspace2</title>           <item>             <day>1</day>             <openingtime>9:00</openingtime>             <closingtime>14:00</closingtime>           </item>           <item>             <day>3</day>             <openingtime>12:00</openingtime>             <closingtime>16:00</closingtime>           </item>         </workspace>        </workplaces>        ') xfield   dual ) select "day", "openingtime", "closingtime" xmltable('$doc//workspace[title=$workspace_filter]/item'               passing (select xfield x) "doc",                       ('workspace1') "workspace_filter"                columns "openingtime" path '//openingtime',                        "closingtime" path '//closingtime',                        "day" path '//day') 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -