Banging my head trying to parse XML
Hi
I am trying to parse an XML in ZOHO CRM.
I was able to add a field for the XML to be uploaded so it can be parsed later
So far I am able to get the file data just fine, and even to get to the important node of the XML (it's embedded with CDATA)
But there are two things I don't know how to do:
1. get values only instead of <key>value</key>
2. how to get a list of values, for instance detalles may contain one or several detalles, so I want to get all of detalles in a collection and parse them in a loop to get the required values.
- if(factura.get("Archivo_XML") != null)
{
file = factura.get("Archivo_XML");
url = file.toCollection().get("download_Url");
url = "https://crm.zoho.com" + url;
file = file.toCollection().get("file_Id");
// to fetch file from the cloud using invokeUrl task
fileVariable = invokeurl
[
url :"https://www.zohoapis.com/crm/v5/files?id=" + file
type :GET
connection:"zoho_crm"
];
//response = fileVariable.getFileContent();
//response = response.toXmlList();
//info "response: " + response.executexpath("autorizacion/estado");
//info "response: " + response.executexpath("autorizacion/numeroAutorizacion");
startFactura = response.find("<infoFactura>");
endFactura = response.find("</infoFactura>");
infoFactura = response.subText(startFactura,endFactura) + "</infoFactura>";
data = infoTributaria.executexpath("infoFactura");
info data;
data = infoTributaria.executexpath("infoFactura/fechaEmision");
info data;
data = infoTributaria.executexpath("infoFactura/totalConImpuestos/totalImpuesto");
info data;
}
This is my current code,
This part:
- data = infoTributaria.executexpath("infoFactura/fechaEmision");
- info data;
Produces
- <fechaEmision>08/09/2023</fechaEmision>