<?xml version="1.0" encoding="UTF-8" ?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:simpleType name="Address" type="xsd:string"/> <xsd:simpleType name="CustomerCode" type="xsd:string"/> <xsd:simpleType name="CustomerName" type="xsd:string"/> <xsd:simpleType name="CodPay" type="xsd:string"/> <xsd:simpleType name="CustDisc" type="xsd:string"/> <xsd:simpleType name="CustType" type="xsd:string"/> <xsd:simpleType name="Mail" type="xsd:string"/> <xsd:group name="shipAndBill"> <xsd:sequence> <xsd:element name="ShipAddress" type="Address"/> <xsd:element name="BillAddress" type="Address"/> </xsd:sequence> </xsd:group> <xsd:complexType name="Customer"> <xsd:sequence> <xsd:choice> <xsd:element name="CustomerCode" type="CustomerCode"/> <xsd:element name="CustomerName" type="CustomerName"/> <xsd:element name="CodPay" type="CodPay"/> <xsd:element name="CustDisc" type="CustDisc"/> <xsd:element name="CustType" type="CustType"/> <xsd:group ref="shipAndBill"/> <xsd:element name="Mail" type="Mail"/> </xsd:choice> </xsd:sequence> </xsd:complexType> <xsd:element name="customer" type="Customer"/> </xsd:schema>
After introspecting the XML schema detailed above, the Project catalog structure appears as shown in the following image:
customer as XMLCOmp.Customer.Customer customer = XMLCOmp.Customer.Customer() customerDOS as XMLCOmp.Customer.Customer customerDOS = XMLCOmp.Customer.Customer() customer.customerCode = "NEW" customer.customerName = "John Smith" customer.custDisc = null customer.billAddress = "Madison 2939 NY" customer.shipAddress = "Madison 2939 NY" customer.codPay = null customer.custType = null customer.mail = "pp@com.com" store customer using targetFile = "C:/tmp/customer.xml"
customer as XMLComp.Customer.Customer
customer = XMLComp.Customer.Customer()
customer.loadFromUrl("file://c:/tmp/customer.xml")
While loadfromUrl( ) method to parse XML documents is interesting from a coding perspective, it is recommended to avoid its use on a large XML file as it uses DOM and reads the whole file into memory.