Presentation is loading. Please wait.

Presentation is loading. Please wait.

Coding With XML Andrew Schwabe

Similar presentations


Presentation on theme: "Coding With XML Andrew Schwabe"— Presentation transcript:

1 Coding With XML Andrew Schwabe aschwabe@gmail.com

2 June 27 th - 30 th 2007www.cfunited.com What This Presentation Is Introduction to XML using ColdFusion How and where XML is used in “real” life (at least a programmers life) How to read, use and create well- formed XML documents

3 June 27 th - 30 th 2007www.cfunited.com Who this presentation is for You like ColdFusion You know how to use structures and arrays You need to (or hope some day to) use XML in your applications

4 June 27 th - 30 th 2007www.cfunited.com About Andrew Schwabe ColdFusion developer since version 3 Worked for web development company for 9 years CTO with IEXP Software Lead Architect for FusionDox IDM Document Management Software (CF based document management)

5 June 27 th - 30 th 2007www.cfunited.com What is XML ?

6 June 27 th - 30 th 2007www.cfunited.com What is XML ? Wikipedia says: Extensible Markup Language (XML) is a general-purpose markup language. It is classified as an extensible language because it allows its users to define their own tags. Its primary purpose is to facilitate the sharing of data across different information systems, particularly via the Internet. XML is meant to be relatively human- readable.

7 June 27 th - 30 th 2007www.cfunited.com What is XML ? eXtensible Markup Language XML is a standard for creating markup languages that describe the structure of data In some form or another (i.e. GML etc.) it has been around since the 70’s

8 June 27 th - 30 th 2007www.cfunited.com What is XML ? eXtensible Markup Language XML is a standard for creating markup languages that describe the structure of data In some form or another (i.e. GML etc.) it has been around since the 70’s This isn’t a history lesson. We have Google

9 June 27 th - 30 th 2007www.cfunited.com In Simplest Terms An XML “document” is a tree of nested elements. Elements use tag syntax to describe information Elements can contain other elements, attributes and text

10 June 27 th - 30 th 2007www.cfunited.com

11 June 27 th - 30 th 2007www.cfunited.com Benefits of Storing Data in XML XML is designed for storing JUST data Forces you to separate data from formatting (good practice!) Human Readable (for the most part) Highly portable between different development languages and operating systems

12 June 27 th - 30 th 2007www.cfunited.com Related Technologies Hyper Text Markup Language (HTML) RSS  Really Simple Syndication  Rich Site Syndication  Rich Syndication Standard  Rich Site Summary

13 June 27 th - 30 th 2007www.cfunited.com Related (cont.) XSLT (Extensible Style sheet Language) WDDX (Web Distributed Data Exchange) Web Services – SOAP (Simple Object Access Protocol) MXML, and many more…

14 June 27 th - 30 th 2007www.cfunited.com Where Do We Use XML ? Web Services and RSS Electronic Data Interchange (EDI) Online XML Services (i.e.. UPS, FedEx, USPS) Storing complex structures of data in files and database fields

15 June 27 th - 30 th 2007www.cfunited.com Where Do We Use XML ? Exchanging data with Flash Movies (Not using Flash Remoting) Reading and Storing content for use by other systems

16 June 27 th - 30 th 2007www.cfunited.com A Practical Example

17 June 27 th - 30 th 2007www.cfunited.com A Practical Example Company X Has an E-Commerce Website Hosted by an ISP Orders are taken online and stored in the web database An outside Fulfillment firm needs to have order data to package and ship orders

18 June 27 th - 30 th 2007www.cfunited.com A Practical Example (cont.) The goal is to maintain security and eliminate double entry (and thus removing human error) Solution: Push orders from the website in XML format and import into fulfillment system

19 June 27 th - 30 th 2007www.cfunited.com

20 June 27 th - 30 th 2007www.cfunited.com Anatomy of an XML Document

21 June 27 th - 30 th 2007www.cfunited.com Anatomy of an XML Document Prolog Body  Elements  Attributes  CDATA  Special Characters

22 June 27 th - 30 th 2007www.cfunited.com Anatomy of an XML Document 512 Goshen Road Bordell OH 35426 } Prolog } Body

23 June 27 th - 30 th 2007www.cfunited.com Anatomy of an XML Document 512 Goshen Road Bordell OH 35426 Attribute Element XML Text

24 June 27 th - 30 th 2007www.cfunited.com Anatomy of an XML Document Arm & Hammer <![CDATA[ This text will be treated as literal, and can contain reserved unescaped characters. ]]> Escaped reserved character CDATA Block

25 June 27 th - 30 th 2007www.cfunited.com Important Terminology

26 June 27 th - 30 th 2007www.cfunited.com Important Terminology “Document Type Definition (DTD)” : A DTD defines strict rules for what can be contained in a specific type of XML Document

27 June 27 th - 30 th 2007www.cfunited.com Important Terminology “Well Formed”: An XML document is well formed if it adheres to all the standard rules for XML (i.e. only one root element, no invalid characters, etc.)

28 June 27 th - 30 th 2007www.cfunited.com Important Terminology “Valid”: An XML document is valid if it is well formed, and also if it adheres to the rules of it’s DTD

29 June 27 th - 30 th 2007www.cfunited.com Important Terminology NOTE: As a general rule, XML documents do not specifically have to have a DTD XML Documents can be well formed without a DTD and be usable

30 June 27 th - 30 th 2007www.cfunited.com SerializationSerialization The process of converting textual data into an XML object is called deserialization The process of converting an XML object back into text is called serialization Web Services handle serialization and deserialization automatically

31 June 27 th - 30 th 2007www.cfunited.com ColdFusion Support ColdFusion MX 6 ColdFusion MX 7 ColdFusion MX 8 BlueDragon Offers Similar and Enhanced functionality

32 June 27 th - 30 th 2007www.cfunited.com XML Basic Functions XmlNew XmlParse XmlElemNew XmlSearch XmlValidate

33 June 27 th - 30 th 2007www.cfunited.com Reading an XML Document Once an XML document is converted to an XML Object in ColdFusion, it becomes a collection of structures and arrays The process of serializing local, transfer data, deserialize remotely is the key to XML

34 June 27 th - 30 th 2007www.cfunited.com Traversing XML Looping over XML Structure

35 June 27 th - 30 th 2007www.cfunited.com Creating a New XML Doc Cheating

36 June 27 th - 30 th 2007www.cfunited.com Creating a New XML Doc Cheating Build Using XmlNew and Arrays and Nodes

37 June 27 th - 30 th 2007www.cfunited.com Storing and Retrieving XML CFFILE CFHTTP Web Services

38 June 27 th - 30 th 2007www.cfunited.com Using WDDX Web Distributed Data Exchange Serializing Arrays and Structures Deserializing WDDX Packets

39 June 27 th - 30 th 2007www.cfunited.com Using WDDX Benefits Easily convert existing CF constructs into XML Deserializing WDDX data results in a standard CF construct

40 June 27 th - 30 th 2007www.cfunited.com XML or WDDX ? Who will need to access the data? Think about the future WDDX is not very widely adopted

41 June 27 th - 30 th 2007www.cfunited.com Validating XML XMLValidate Optional: specify a DTD Returns “errors” – determine if the XML Document is “Valid” Returns “fatalerrors” – determine if the XML Document is “Well Formed”

42 June 27 th - 30 th 2007www.cfunited.com XML Search

43 June 27 th - 30 th 2007www.cfunited.com ExamplesExamples XML Site Navigation Create the definition of a navigation system in XML Read the XML and dynamically build the navigation system

44 June 27 th - 30 th 2007www.cfunited.com Managed Website Prefs Website settings stored in XML Web page to allow users to modify settings

45 June 27 th - 30 th 2007www.cfunited.com Fedex Rate Lookup Retrieve dynamic rate service quotes using UPS online tools

46 June 27 th - 30 th 2007www.cfunited.com Tips and Tricks Dealing with HTTP Compression and Web Services

47 June 27 th - 30 th 2007www.cfunited.com Where to look next Google XML Support in SQL Server 2005

48 June 27 th - 30 th 2007www.cfunited.com Coding With XML - Updated Stuff Copy of updated presentation and sample files are posted at: http://www.schwabe.net/blog/ Contact me at: aschwabe@gmail.com (courtesy of engrish.com)


Download ppt "Coding With XML Andrew Schwabe"

Similar presentations


Ads by Google