?xml version="1.0" encoding="utf-8"?>
<ns0:Documents
xmlns:ns0="D365InvoiceIngoing">
<ns0:Document DocumentReference="" ImageReference="" CertificateReference="" Version="1.0" Name="XML Invoice" Type="Invoice">
<ns0:Invoice>
<ns0:Supplier>
<ns0:Number>200003</ns0:Number>
</ns0:Supplier>
<ns0:Buyer>
<ns0:CorporateGroupNumber>BOC</ns0:CorporateGroupNumber>
</ns0:Buyer>
<ns0:Fields>
<ns0:Field Name="Faktura/Kredit" Type="invoicecredit">Invoice</ns0:Field>
<ns0:Field Name="Fakturanummer" Type="invoicenumber">PSI871887</ns0:Field>
<ns0:Field Name="Fakturadato" Type="invoicedate">20210326</ns0:Field>
<ns0:Field Name="Momsbeløb" Type="invoicetotalvatamount">0.00</ns0:Field>
<ns0:Field Name="Totalbeløb" Type="invoicetotalvatincludedamount">401.60</ns0:Field>
<ns0:Field Name="Girostreng" Type="paymentreferencenumber"></ns0:Field>
<ns0:Field Name="Valuta" Type="invoicecurrency"></ns0:Field>
<ns0:Field Name="Ordrenummer" Type="invoiceordernumber">PO2167913</ns0:Field>
<ns0:Field Name="Rekvirent" Type="buyercontactpersonname"></ns0:Field>
<ns0:Field Name="FSCCert" Type="FSCCert"></ns0:Field>
</ns0:Fields>
<ns0:Tables />
<ns0:Attachments />
<ns0:InvoiceLines>
<ns0:InvoiceLine>
<ns0:Field Name="Varenummer" Type="ItemNumber">ABCD</ns0:Field>
<ns0:Field Name="Antal" Type="Quantity">15</ns0:Field>
<ns0:Field Name="FSCClaim" Type="FSCClaimValue"></ns0:Field>
</ns0:InvoiceLine>
<ns0:InvoiceLine>
<ns0:Field Name="Varenummer" Type="ItemNumber">BCDE</ns0:Field>
<ns0:Field Name="Antal" Type="Quantity">10</ns0:Field>
<ns0:Field Name="FSCClaim" Type="FSCClaimValue"></ns0:Field>
</ns0:InvoiceLine>
<ns0:InvoiceLine>
<ns0:Field Name="Varenummer" Type="ItemNumber">ABCDE</ns0:Field>
<ns0:Field Name="Antal" Type="Quantity">10</ns0:Field>
<ns0:Field Name="FSCClaim" Type="FSCClaimValue"></ns0:Field>
</ns0:InvoiceLine>
</ns0:InvoiceLines>
</ns0:Invoice>
<ns0:System>
<ns0:Field Type="Pages">\\d365iwfprodstorage.file.core.windows.net\d365iwfprod\read\xml\PSI871487.pdf</ns0:Field>
<ns0:Field Type="DateTime">20210410 00:03:49</ns0:Field>
<ns0:Field Type="Currency"></ns0:Field>
<ns0:Field Type="Originator">Biztalk</ns0:Field>
<ns0:Field Type="ImageFile1">\\d365iwfprodstorage.file.core.windows.net\d365iwfprod\read\xml\PSI871487.pdf</ns0:Field>
</ns0:System>
<ns0:ProcessLog>
<ns0:ProcessMessage>
<ns0:TimeStamp>2021-04-10T00:03:49</ns0:TimeStamp>
<ns0:Type>System</ns0:Type>
<ns0:Module>Verify</ns0:Module>
<ns0:Action>Approved</ns0:Action>
<ns0:Owner>administrator</ns0:Owner>
<ns0:sMessage></ns0:sMessage>
</ns0:ProcessMessage>
</ns0:ProcessLog>
</ns0:Document>
</ns0:Documents>
trying to read above XML using X++ jobs but getting error
static void readXMLString_Copy(Args _args)
{
// Define XML Document and its nodes
XmlDocument doc,Doc1;
XmlNodeList xmlScriptList,XmlNodeListOne;
XmlNodeList xmlProjectList;
XmlElement nodeScript;
XmlElement nodeProject;
XmlElement nodeNote;
XMLParseError xmlError;
XmlElement firstName;
// Define temporary variables
str _xmlMsg;
int i, j;
str 10000 note;
#define.filename(@'C:\AIF\XML\InvoiceTestSingleLineWithFSC.xml');
Doc1 = XmlDocument::newFile(#filename);
note = Doc1.toString();
// Create the XML Document
doc = new XmlDocument();
doc.loadXml(note);
//doc = XmlDocument::newXml(#filename);
// Verify XML Document Structure
xmlError = doc.parseError();
if(xmlError && xmlError.errorCode() != 0)
{
throw error(strFmt("XML Error: %1", xmlError.reason()));
}
// Get the root element and its child nodes
// xmlScriptList = doc.getElementsByTagName("ns0:Invoice");
// Get the root element and its child nodes
// nodeScript = doc.getNamedElement("ns0:Document");
xmlScriptList = doc.selectNodes("Invoice");
//xmlScriptList = nodeScript.childNodes();
//xmlScriptList = nodeScript.childNodes();
for(i=0; i < xmlScriptList.length(); i++)
{
nodeProject = xmlScriptList.item(i);
xmlProjectList = nodeProject.childNodes();
info("### Project information: ");
info(strFmt("ItemNumber: %1", nodeScript.getAttribute("ItemNumber")));
/*firstName = nodeScript.getAttribute("Fakturanummer");
if (firstName)
{
info(strFmt("First Name: %1", firstName.text()));
}*/
//info(strFmt("ItemNumber: %1", nodeProject.getAttribute("ItemNumber")));
//info(strFmt("To: %1", nodeProject.getElementsByTagName("ItemNumber").text()));
// Loop through the repeating nodes
//info("### Notes: ");
for (j=2; j < xmlProjectList.length(); j++)
{
nodeNote = xmlProjectList.item(j);
info(strFmt("ItemNumber: %1", nodeNote.getAttribute("Varenummer")));
info(strFmt("To: %1", nodeNote.getNamedElement("Varenummer").text()));
//info(strFmt("Body: %1", nodeNote.getNamedElement("Body").text()));
}
}
}
any suggestion will great help.