Oracle XML xpath get value of current node in loop



This is my XML returned from the URL I call



<?xml version="1.0" encoding="ISO-8859-1"?>
<xml_calls>
<calls ip="46.32.238.33">1038791</calls>
<calls ip="212.44.61.2">3</calls>
<calls ip="81.86.144.86">2</calls>
</xml_calls>


and this is my code I call to parse the XML



declare
doc xmldom.DOMDocument;

data_list xmldom.DOMNodeList;
data xmldom.DOMNode;

Line_node_list xmldom.DOMNodeList;
Line_node xmldom.DOMNode;
begin

doc := xml.parseURL('http:// .... url to my xml doc ....');

data_list := xpath.selectNodes(doc, '//xml_calls');
data := xmldom.item(data_list, 0); -- node list index is zero based

-- open the line_no node
Line_node_list := xpath.selectNodes(data, './calls');

for i in 1 .. xmldom.getLength(Line_node_list) loop
Line_node := xmldom.item(Line_node_list, i-1);

dbms_output.put_line(xpath.valueOf(Line_node, './calls'));
dbms_output.put_line(xpath.valueOf(Line_node, './@ip'));

end loop;
end;


how can I get the value of the current node in the loop, ie the value of "calls" as in the loop xpath.valueOf(Line_node, './calls') returns null. Outside of the loop obviously it just returns the first value, 1038791


Am I missing something?


Thanks


No comments:

Post a Comment