Hello,
The following process needs to be “automated” and it was submitted as this:
We send our accounts payable bills to an external company which will produce XML files with them and send us back the XML by e-mail.
I was asked to create a XML reader app to save the XML into a DB table. Then from the table they will generate the Excel file to use in a DMT import into Epicor.
My first thought was hey I can create the excel file directly, no need to use the DB table.
Then I tought… isn’t REST could be used and so write automatically into Epicor without using DMT ? (did not yet touched REST yet… )
Depends on where you are inserting these records. If you are doing in the a UD table you should have no issues. Most REST services are calling METHODS where the DMT does not. Have you tried opening the XML in Excel. Excel will parse out the XML though its not always correct.
The issue I have is being able to interpret the XML file to start with. How to read the different nodes … I know that each file is one invoice. But each invoices can have multiple lines. Here is a sample of the file: Right now, all I read is the InvoiceHeader info…via
DataSet dsXMLReader = new DataSet();
dsXMLReader.ReadXml(file.FullName);
I need to differentiate the header info vs the multiple line info. in order to save the header in a one temp table, and lines in another temp table.
(for now I just want to show them in two datagrids…)
@Hogardy all I know about XML I have learned in the last 48 hours, so there are likely better ways to get there, but I am doing something like that with code like this that I cobbled together from samples.
XmlDocument doc = new XmlDocument();
using (StreamReader streamReader = new StreamReader(file.Directory +"\\" + file.Name, Encoding.UTF8))
{
contents = streamReader.ReadToEnd();
}
doc.LoadXml(contents);
XmlNodeList nodeList;
nodeList=doc.SelectNodes("//INVOICE/INVOICEHEADER");
foreach (XmlNode node in nodeList)
{
invoiceID= node.SelectSingleNode( "INVOICEID").InnerText;
...
}
nodeList=doc.SelectNodes("//INVOICE/BOOKLINES/BOOKLINE");
foreach (XmlNode node in nodeList)
{
booklineID= node.SelectSingleNode( "BOOKLINEID").InnerText;
...
}