I am trying to generate a dynamic insert by taking an XML file but I can not extract the merchandise attributes for another string. So far I was able to extract the first 4
You have to follow this structure
--Parseo el contenido del documento xml
v_parse := xmlparser.newparser();
xmlparser.parseclob(v_parse, v_xml);
--Obtenemos el documento xml cargado en un objeto DOM
v_doc := xmlparser.getdocument(v_parse);
xmlparser.freeparser(v_parse);
v_nodos := xmldom.getChildrenByTagName(xmldom.getDocumentelement(v_doc), '*');
--Recorremos cada nodo del arreglo, el arreglo inicio en el item 0 --- Aca devuelve 7
FOR j IN 1 .. xmldom.getlength(v_nodos) loop
v_nodo := xmldom.item(v_nodos,j-1);
-- obtenemos la lista d eelementos que tiene el nodo actual
v_nodos_hijo := xmldom.getchildnodes(v_nodo);
--recorremos los atributos del nodo, obtenemos la lista de atributos que tiene el nodo
v_atributos := xmldom.getattributes(v_nodo);
--recorremos cada atributo del nodo
vv_linea := 'INSERT INTO Fundamento (CODIGO, DESCRIPCION, FEC_INI, FEC_FIN, COD_MONEDA) VALUES (' ;
FOR k IN 1 .. xmldom.getlength(v_nodos_hijo) LOOP
--obtenemos un elemento
v_elemento := xmldom.item(v_nodos_hijo, k-1);
IF k = 1 THEN
vv_linea := vv_linea ||CHR(39)||xmldom.getnodevalue(xmldom.getfirstchild(v_elemento))||CHR(39)||',' ;
ELSIF k = 2 THEN
vv_linea := vv_linea ||CHR(39)||xmldom.getnodevalue(xmldom.getfirstchild(v_elemento))||CHR(39)||',' ;
ELSIF k = 3 THEN
vv_linea := vv_linea ||'TO_DATE('||CHR(39)||xmldom.getnodevalue(xmldom.getfirstchild(v_elemento))||CHR(39)||','||CHR(39)||'dd/MM/yyyy'||CHR(39)||'),' ;
ELSIF k = 4 THEN
vv_linea := vv_linea ||'TO_DATE('||CHR(39)||xmldom.getnodevalue(xmldom.getfirstchild(v_elemento))||CHR(39)||','||CHR(39)||'dd/MM/yyyy'||CHR(39)||'))';
END IF;
vv_linea := REPLACE (vv_linea, 'TO_DATE('||CHR(39)||'-'||CHR(39)||','||CHR(39)||'dd/MM/yyyy'||CHR(39)||')' , 'NULL');
END LOOP;
dbms_output.put_line(vv_linea);
END LOOP;
END;
Could someone help me know what methods I should use to extract the merchandise section?
Thank you!