140 likes | 292 Views
XML, CFMX CFML & SQL XML. Kevin Penny, MMCP kevin@hotgigs.com. What is XML?. Animal, vegetable, or mineral? Best reference: www.w3schools.com XML stands for E X tensible M arkup L anguage XML was designed to describe data XML can be used to Share Data/Store Data, Create New Languages
E N D
XML, CFMX CFML & SQL XML Kevin Penny, MMCP kevin@hotgigs.com
What is XML? • Animal, vegetable, or mineral? • Best reference: www.w3schools.com • XML stands for EXtensible Markup Language • XML was designed to describe data • XML can be used to Share Data/Store Data, Create New Languages • XML is designed to be self-descriptive • <Animal> • <Dog name=“Bailey”> • <Type>Golden Retriever</Type> • </Dog> • </Animal>
XML Uncovered • <?xml version="1.0" encoding="ISO-8859-1"?> • <Animal> • <Dog name=“Bailey”> • <Type>Golden Retriever</Type> • </Dog> • </Animal> XML Declaration ATTRIBITE ROOT ELEMENT ELEMENT
Rules of the Road • XML is cAsE Sensitive • Elements must have a closing tag • Elements must be properly nested • Attribute values must be quoted • All XML documents must have a root element
CFML and XML • New great XML functions • XMLParse(xmlDocument) • Creates a tree structure of the XML document as an array of structures • Data can come from a database query, a file on the server, an http request etc. • XMLSearch(xmlDocument, xPathString) • Used to navigate/search an xml document using elements (walking the nodes) • XMLFormat(string) • Used to escape special XML characters in a string so that it is safe to use with XML • < > ‘ “ & • XMLTransform(xmlDocument,xslString) • Applies an XSLT to an XML document • XMLNew() or <CFXML • Creates an XML Document • Great Reference • http://www.how2cf.com/files/papers/cfxml.pdf
CFML XML in Action Let’s Dive in Example Create Parse Search Extract Cfug/Index.cfm CFML XML IA
SQL XML • Microsoft SQL Server 2000’s support for XML • Creating queries that create an XML output • FOR XML Cause • Inputting XML to a procedure that can manipulate the XML Document and put the data into a table etc. • i.e. Complex form data can be passed to a stored procedure and manipulated • sp_xml_preparedocument • OPENXML
SQL XML meets CFML XML • Example • SQL Query as XML • SQL OPENXML Example in a Stored Procedure • CFML Call to the Procedure inserting the XML Document
Questions? • DTD’s? • XPath • XSLT • Schemas • SQL OPENXML
References • CFML XML • http://www.how2cf.com/files/papers/cfxml.pdf • XML • www.w3schools.com