Presentation is loading. Please wait.

Presentation is loading. Please wait.

What is XML (Extensible Markup Language)? XML is basically a better comma delimited file. Example: Your client asks you to write a new reporting system.

Similar presentations


Presentation on theme: "What is XML (Extensible Markup Language)? XML is basically a better comma delimited file. Example: Your client asks you to write a new reporting system."— Presentation transcript:

1 What is XML (Extensible Markup Language)? XML is basically a better comma delimited file. Example: Your client asks you to write a new reporting system for an application that was written five years ago. Nobody who originally worked on the application is still at the company. You have to figure out how the app works, parse the data that it produces and arrange the data into a report. The application gives you data that looks like this: Jones, Washer, 401.56, New York Janson, Blender, 56.90, Austin Newton, Mixer, 90.00, Waco This is a comma delimited document. Each column is separated by a comma and each record is on a different row.

2 What is XML? Jones, Washer, 401.56, New York Janson, Blender, 56.90, Austin Newton, Mixer, 90.00, Waco Problems with delimited data: What happens if the data itself includes a comma? You have to put quotes around the data Different documents use different delimiters – so you to write a parser for each delimiter Different OS have different ideas about what makes the end of a line carriage return vs. line feed What is this data? Name?, Item?, What is the number? Without documentation, we have no idea Can’t represent related data customers and orders in the same document hard to represent a hierarchy Can’t add new fields without breaking the parser

3 What is XML? Same data in XML Jones Washer 401.56 New York Janson Blender 56.90 Austin Newton Mixer 90.00 Waco

4 Advantages of XML? XML documents are readable and self describing tags indicate what each piece of data is XML is interoperable – not tied to any operating system or technology create documents using a text editor Parsers exist for virtually every operating system XML documents are hierarchical easy to add related data You don’t have to write the parser many already exist Changes to the document do not break the parser you can add elements without breaking backward compatibility XML lets you concentrate on writing the application instead of worrying about the details of the parser.

5 XML Document Structure and Syntax Declaration First line of every document. Always the same. Not required. Tells you two things It’s and xml document It conforms to the XML 1.0 W3C recommendation Elements elements are what contain the data sometimes called nodes documents must have at least one top level element Most basic XML document

6 XML is very picky Most basic XML document Every element must have an open and a closing tag Declaration is the only element that does not need a closing tag XML is case sensitive orders is different from Orders or ORDERS

7 Elements that contain Data 1/4/200 33456 Steve Moore 4563.44 Description in English: It contains a top level ORDERS element and a single ORDER element, or node. The ORDER node is a child of the ORDERS element. The ORDER element itself contains four child nodes of its own: DATETIME, ID, CUSTOMER, and TOTALAMOUNT.

8 Elements that contain Data A document containing two orders 1/4/2000 33456 Steve Moore 4563.44 1/5/2000 56756 Jane Wolf 3456.89

9 Attributes Attributes are another way to enclose a piece of data in an XML document. An Attribute is part of an element. It usually modifies or is related to the information in the element. 1/4/200 4563.44 Attribute values are enclosed in quotes. You can use single or double quotes wherever needed.

10 CDATA The < character and the & character and throw off the XML parser. The following could cause a problem Jones & Williams CPA 1/4/200 4563.44 You can use the a CDATA element to handle this. CDATA tells the parser not to interpret or parse the characters in the CDATA element 1/4/200 4563.44

11 Abbreviated Close Tags For elements that do not contain data you can use abbreviated syntax. Jones & Williams CPA 1/4/200 instead of 1/4/200

12 XML Tools Microsoft XML Notepad – simple tool for creating XML http://msdn.microsoft.com/library/default.asp?url=/library/en- us/dnxml/html/xmlpaddownload.asp

13 XML Tools XML Spy – full featured tool XML editor built into Visual Studio.Net

14 using the dom ado xml method example app w treeview? XML Tools XML Spy – full featured tool XML editor built into Visual Studio.Net

15


Download ppt "What is XML (Extensible Markup Language)? XML is basically a better comma delimited file. Example: Your client asks you to write a new reporting system."

Similar presentations


Ads by Google