How should you read in a large and complex XML file?
Reading a very large and complex XML file into memory all at once is not efficient. It causes large amounts of memory to be consumed and will degrade the Engine's performance.
By having an XSD file that you can introspect, there is a much more efficient technique that does not require that the whole file be read into memory. The code shown below does not read the XML whole file into memory and only accesses the file when it needs to read in more object information from it.
// In production, do not hard code a local directory
// like this.
// It is only here in this example for clarity.
customer as XMLCOmp.Customer.Customer
customer =
XMLCOmp.Customer.Customer("file://c:/tmp/customer.xml")
display customer.billAddress
display customer.custDisc
display customer.customerName
<?xml version="1.0" encoding="ISO-8859-1" ?> <Customer> <CustomerCode>NEW</CustomerCode> <CustomerName>John Smith</CustomerName> <CustDisc></CustDisc> <BillAddress>Madison 2939 NY</BillAddress> <ShipAddress>Madison 2939 NY</ShipAddress> <CodPay></CodPay> <CustType></CustType> <Mail>pp@com.com</Mail> </Customer>