How to get XML tag attribute in a PL/SQL package from oracle

Here is my tag XML :
<Individual>
     <ByName FreeReference="REFERENTIE DN">
     </ByName>
</Individual>

I want to get the value equal to freereference (= attribute of byname).
I know how to get a value in a tag (XSLPROCESSOR.VALUEOF) but I cannot get the attribute value. I think i had to use XMLDOM.GETATTRIBUTES but I can find the way to use it.

How can I do that ?

Thanks a lot.
fba_mainsysAsked:
Who is Participating?
 
vanmeerendonkConnect With a Mentor Commented:
I hacked a small example
you should be able to read that

declare
  l_clob clob;
  l_parser    xmlparser.PARSER;
  l_doc       xmldom.DOMDOCUMENT;
  l_node_list xmldom.DOMNODELIST;
  l_root      xmldom.DOMNODE;
begin
  l_clob:= dbms_xmlquery.getxml('select col1 "@ref", kol2 "KOL_2" from table where rownum <= 1') ;
  l_parser := xmlparser.newparser;
  xmlparser.setvalidationmode(l_parser, FALSE);
  xmlparser.parseclob(l_parser,l_clob);
    l_doc       := xmlparser.getDocument(l_parser);
    l_node_list := xmldom.getelementsbytagname(l_doc, '*');
    l_root      := xmldom.item(l_node_list,1);
    pl(xmldom.getnodevalue(xmldom.getNamedItem(xmldom.getattributes(l_root),'ref')));
    xmldom.freeDocument (l_doc);
  xmlparser.freeparser(l_parser);
END ;
/
0
 
fba_mainsysAuthor Commented:
Thanks a lot, it works fine !!
0
All Courses

From novice to tech pro — start learning today.