How to check if given node exists in XML document?
XML example:
<order>
<desc>
<name>Test name</name>
<code>Test code</code>
</desc>
<suborders>
<item>
<id>1000</id>
</item>
<item>
<id>2000</id>
</item>
</suborders>
<options>
<item/>
</options>
</order>
How to check in PL/SQL if any suborder's item exists?
I tried like this:
DECLARE
myxml CLOB := ...
BEGIN
SELECT extractValue(XMLTYPE(myxml), '/order/suborders/item[1]')
INTO firstSuborder
FROM DUAL;
IF (firstSuborder IS NULL) THEN
dbms_output.put_line('suborder doesnt exist');
END IF;
END;
but I got ORA-19025: EXTRACTVALUE returns value of only one node.