Her er en lille anonymous block der løser dit problem:
/*
CREATE TABLE currency_tab
(
currency_code varchar2(10),
currency_rate varchar2(10)
);
*/
DECLARE
t_cc currency_tab%ROWTYPE;
l_xmltext VARCHAR2 (4000) := '<?xml version="1.0" encoding="ISO-8859-1" ?>
<exchangerates type="Valutakurser" author="Danmarks Nationalbank" refcur="DKK" refamt="1" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"> <dailyrates id="2011-01-21">
<currency code="EUR" desc="Euro" rate="745,33" />
<currency code="USD" desc="Amerikanske dollars" rate="551,24" />
<currency code="GBP" desc="Britiske pund" rate="878,67" />
<currency code="SEK" desc="Svenske kroner" rate="83,19" />
<currency code="NOK" desc="Norske kroner" rate="94,44" />
<currency code="ISK" desc="Islandske kroner" rate="-" />
<currency code="CHF" desc="Schweiziske franc" rate="572,76" />
<currency code="CAD" desc="Canadiske dollars" rate="553,12" />
<currency code="JPY" desc="Japanske yen" rate="6,6625" />
<currency code="AUD" desc="Australske dollars" rate="545,39" />
<currency code="NZD" desc="New Zealandske dollars" rate="417,69" />
<currency code="LVL" desc="Lettiske lats" rate="1.059,46" />
<currency code="LTL" desc="Litauiske litas" rate="215,86" />
<currency code="PLN" desc="Polske zloty" rate="192,35" />
<currency code="CZK" desc="Tjekkiske koruna" rate="30,69" />
<currency code="HUF" desc="Ungarske forint" rate="2,718" />
<currency code="HKD" desc="Hongkong dollars" rate="70,78" />
<currency code="SGD" desc="Singapore dollars" rate="429,26" />
<currency code="ZAR" desc="Sydafrikanske rand" rate="77,22" />
<currency code="BGN" desc="Bulgarske lev" rate="381,09" />
<currency code="RON" desc="Rumænske lei" rate="174,85" />
<currency code="TRY" desc="Tyrkiske lira" rate="349,77" />
<currency code="KRW" desc="Sydkoreanske won" rate="0,4919" />
<currency code="HRK" desc="Kroatiske kuna" rate="100,80" />
<currency code="RUB" desc="Russiske rubel" rate="18,40" />
<currency code="THB" desc="Thailandske baht" rate="17,96" />
<currency code="MYR" desc="Malaysiske ringgit" rate="180,14" />
<currency code="PHP" desc="Filippinske peso" rate="12,40" />
<currency code="IDR" desc="Indonesiske rupiah" rate="0,0608" />
<currency code="CNY" desc="Kinesiske Yuan renminbi" rate="83,73" />
<currency code="BRL" desc="Brasilianske real" rate="329,72" />
<currency code="MXN" desc="Mexikanske peso" rate="45,68" />
<currency code="INR" desc="Indiske rupee" rate="12,08" />
<currency code="ILS" desc="Israelske shekel" rate="151,75" />
<currency code="SDR" desc="Special Drawing Rights" rate="857,24" />
</dailyrates>
</exchangerates>';
l_xmlin XMLTYPE;
l_xmlout XMLTYPE;
l_clob CLOB;
l_dom DBMS_XMLDOM.DOMDOCUMENT;
Node DBMS_XMLDOM.DOMELEMENT;
NodeList DBMS_XMLDOM.DOMNODELIST;
AttrNode DBMS_XMLDOM.DOMATTR;
ListLen NUMBER;
n NUMBER;
BEGIN
-- l_xmlout := webservicecall (l_xmlin, 'portname', 'operationname');
-- Ovenstående er koden der kalder en webservice og returnerer XML i l_xmlout.
-- l_xmlin er f.eks. din XML-request (hvis altså Nationalbanken stiller en webservice til rådighed - ellers må du fylde l_xmlin på anden vis)
l_xmlout := xmltype(l_xmltext);
l_clob := l_xmlout.getclobval ();
l_dom := DBMS_XMLDOM.NEWDOMDOCUMENT (l_clob);
NodeList :=
DBMS_XMLDOM.GETELEMENTSBYTAGNAME (l_dom,'currency');
ListLen := DBMS_XMLDOM.GETLENGTH (NodeList);
IF ListLen > 0
THEN
FOR n IN 0 .. ListLen - 1
LOOP
Node :=
DBMS_XMLDOM.MAKEELEMENT (DBMS_XMLDOM.ITEM (NodeList, n));
AttrNode := DBMS_XMLDOM.GETATTRIBUTENODE(node,'code');
t_cc.currency_code := DBMS_XMLDOM.GetValue (AttrNode);
AttrNode := DBMS_XMLDOM.GETATTRIBUTENODE(node,'rate');
t_cc.currency_rate := DBMS_XMLDOM.GetValue (AttrNode);
INSERT INTO currency_tab
VALUES t_cc;
END LOOP;
END IF;
END;