90 likes | 111 Views
XML – What to do with it Using XML in VDF. John Tuohy Data Access Worldwide. An XML Document Consists of. PIs – Processing Instructions DTDs Root Element (or Document Element) The root contains all other elements Elements Elements contain child elements, attributes, Text Data Attributes
E N D
XML – What to do with itUsing XML in VDF John Tuohy Data Access Worldwide
An XML Document Consists of PIs – Processing Instructions DTDs Root Element (or Document Element) The root contains all other elements Elements Elements contain child elements, attributes, Text Data Attributes Character Data Text data or CDataSection
An XML Document <CUSTOMERLIST> <CUSTOMER PRODUCT="Food"> <NAME>Ming Foo Bakery</NAME> <ADDRESS> <STREET>1199 Sutter St</STREET> <CITY>San Francisco</CITY> </ADDRESS> </CUSTOMER> </CUSTOMERLIST>
<CUSTOMERLIST> An XML Document as DOM Nodes <CUSTOMER> PRODUCT=“Food” <NAME> <ADDRESS> <CITY> Ming Foo Bakery <STREET> San Francisco 1199 Sutter St
The Main XML Classes in VDF cXmlDomNode cXmlDomDocument cXmlDomElement cXmlDomAttribute cXmlDomCharacterData cXMLDomTextNode cXMLDomCDataSection NodeCollection cXmlDomNodeList cXmlDomNamedNodeMap
The cXmlDomDocument Interface Get Create U_cXMLDOMDocument to hoXML Set psDocumentName of hoXML to sName Set pbValidateOnParse of hoXML To bState Get LoadXMLDocument of hoXML to bTest Get DocumentElement of hoXML to hoRoot Get CreateDocumentElement of hoXML sRoot to hoRoot Get SaveXMLDocument of hoXML to bTest Send Destroy Of hoXML
The cXMLDomElement Interface Get FindNode of hoEle sQuery to hoNode Get FindNodeList of hoEle sQuery to hoNode Get ChildNodeValue of hoEle sTagName to sValue Get AttributeValue of hoEle sAttribute to sValue Get AddElement of hoEle sTagName sData to hoNode Send AddElement of hoEle sTagName sData Send AddAttribute of hoEle sAttribute sData Send AddChildTexNode of hoEle sData Send AddCDataSection of hoEle sData
The cXmlNodeList Interface Get NodeListLength of hoNodeList to iItems Get CollectionNode of hoNodeList iItem to hoNode Get FindNodeList of hoRoot "CUSTOMER" to hoList Get NodeListLength of hoList to iItems Decrement iItems For i from 0 to iItems Get CollectionNode of hoList i to hoCust Send ShowCust hoCust Send Destroy of hoCust Loop send Destroy of hoList
Transforming Data – using XSLT Get XSLTransformation of hoRoot hoXSL to sHTMLData Get Create U_cXMLDOMDocument to hoXML Set psDocumentName of hoXML to (sPath - "\customer.xml") Get LoadXMLDocument of hoXML to bOK Get DocumentElement of hoXML to hoRoot Get Create U_cXMLDOMDocument to hoXSL Set psDocumentName of hoXSL to (sPath - "\customer.xsl") Get LoadXMLDocument of hoXSL to bOK Get XSLTransformation of hoRoot hoXSL to sHTMLData Direct_Output Channel 0 (sPath - "\NewCustomer.html") writeln Channel 0 sHTMLData Close_Output Channel 0 Send Destroy of hoXSL Send Destroy of hoXML