Does anybody know how to retrieve the values of <ZIPCODE>
and <CITY>
using PL/SQL? I have followed a tutorial over the net, however, it can retrieve the element names, but not their values. Any of you know what seems to be the problem? I have already consulted Google (the internet's well kept secret) over this but no luck :(
<Zipcodes>
<mappings Record="4">
<STATE_ABBREVIATION>CA</STATE_ABBREVIATION>
<ZIPCODE>94301</ZIPCODE>
<CITY>Palo Alto</CITY>
</mappings>
</Zipcodes>
here's the sample code:
-- prints elements in a document
PROCEDURE printElements(doc DBMS_XMLDOM.DOMDocument) IS
nl DBMS_XMLDOM.DOMNodeList;
n DBMS_XMLDOM.DOMNode;
len number;
BEGIN
-- get all elements
nl := DBMS_XMLDOM.getElementsByTagName(doc, '*');
len := DBMS_XMLDOM.getLength(nl);
-- loop through elements
FOR i IN 0 .. len - 1 LOOP
n := DBMS_XMLDOM.item(nl, i);
testr := DBMS_XMLDOM.getNodeName(n) || ' ' || DBMS_XMLDOM.getNodeValue(n);
DBMS_OUTPUT.PUT_LINE (testr);
END LOOP;
DBMS_OUTPUT.PUT_LINE ('');
END printElements;