ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / XML file functions
  • Finding the invoices in an XML file
Finding the invoices in an XML file
WINDEVWEBDEV - Server codeReports and QueriesJavaUser code (UMC)PHP
sMyXMLDoc is string = "XML"
sXMLInfo is string
 
// Load the XML file in a string
sXMLInfo = fLoadText(CompleteDir(fExeDir()) + "Invoice.xml")
 
// Initialize the XML functions on this file
XMLDocument(sMyXMLDoc, sXMLInfo)
 
// Position on the root
XMLRoot(sMyXMLDoc)
 
// Read while finding the invoices and the information
// about these invoices (structure of XML file known)
LOOP
// Find an "Invoice" in the elements and/or sub-elements
XMLFind(sMyXMLDoc, "INVOICE", XMLElement + XMLChildItem + XMLContinue, ...
XMLIgnoreCase + XMLExact)
IF XMLFound(sMyXMLDoc) = False THEN BREAK
// An invoice was found
// Information about the invoice
XMLChild(sMyXMLDoc)
XMLFirst(sMyXMLDoc)
WHILE XMLOut(sMyXMLDoc) = False
SWITCH XMLElementName(sMyXMLDoc)
CASE "NUMBER"
Trace("Invoice # " + XMLData(sMyXMLDoc))  
CASE "TOTAL"
Trace("Invoice amount: " + XMLData(sMyXMLDoc))
CASE "VAT"
Trace("VAT " + XMLData(sMyXMLDoc))
CASE "NOTES"
Trace("Notes: " + XMLData(sMyXMLDoc))
CASE "INVOICE_LINE"
// Details of lines for the current invoice
// Information about an invoice line
XMLChild(sMyXMLDoc)
XMLFirst(sMyXMLDoc)
WHILE XMLOut(sMyXMLDoc) = False
SWITCH XMLElementName(sMyXMLDoc)
CASE "NUMBER"
Trace("Invoice # " + XMLData(sMyXMLDoc))
CASE "AMOUNT"
Trace("Amount of the line: " + ...
XMLData(sMyXMLDoc))
CASE "DESCRIPTION"
Trace("Description of the line: " + ...
XMLData(sMyXMLDoc))
OTHER CASE
// Don't retrieve the other information
// about the line, move up to the level of
// invoice details
XMLParent(sMyXMLDoc)
END
XMLNext(sMyXMLDoc)
END
// Move up to the level of invoice details
XMLParent(sMyXMLDoc)
  OTHER CASE
// Don't retrieve the other invoice information
 END
 XMLNext(sMyXMLDoc)
END
// Move up to the invoice level
XMLParent(sMyXMLDoc)
END
// Cancels the search for the other possible XML functions used thereafter
XMLCancelSearch(sMyXMLDoc)
// Frees the XML document
XMLClose(sMyXMLDoc)
Info("Browse of invoices completed")
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help