Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unit 8 XML Documents. Key Concepts XML fundamentals XML document format Document declaration XML elements and attributes Parsing Characters and white.

Similar presentations


Presentation on theme: "Unit 8 XML Documents. Key Concepts XML fundamentals XML document format Document declaration XML elements and attributes Parsing Characters and white."— Presentation transcript:

1 Unit 8 XML Documents

2 Key Concepts XML fundamentals XML document format Document declaration XML elements and attributes Parsing Characters and white space Reserved characters CDATA XML namespaces

3 XML Fundamentals Stored as text files. Can be created with any text editor. Hierarchical data storage format. Must contain at least one (root) element. File names end in.xml extension by default, but vary with use.

4 Sample XML Document 1 2 3 4 5 6 7 Welcome to XML! 8

5 Key Points Elements are enclosed in angle brackets <>. The root element is the first element opened and last element closed. Inner elements in the hierarchy are called child elements.

6 Common Programming Errors Attempting to create more than one root element. Not adhering to case on element tags. Improper nesting.

7 Improper Nesting Hello World

8 XML Parsing

9 Parsing Failure

10 Characters Supports ASCII and Unicode characters Markup text is enclosed in angle brackets Character data is inserted between tags White space characters include spaces, line feeds, and carriage returns.

11 Reserved Characters Reserved for use by XML –Ampersand (&) –Left angle bracket (<) –Right angle bracket (>) –Apostrophe (') –Double quote (") Built-in entities –Ampersand (&) Built-in entities –Ampersand (&) –Left angle bracket (<) –Right angle bracket (>) –Apostrophe (&apos;) –Double quote (")

12 Book Sample = 1 2 3 4 5 6 7 8 9 Deitel&s XML Primer 10 11 12 Paul 13 Deitel 14 15 16 17 Welcome 18 Easy XML 19 XML Elements? 20 Entities 21 22 23 24

13 Book Sample (cont'd)

14 CDATA Example 1 2 3 4 5 6 7 8 9 // C++ comment 10 if ( this->getX() < 5 && value[ 0 ] != 3 ) 11 cerr << this->displayError(); 12 13 14 15 <![CDATA[ 16 17 // C++ comment 18 if ( this->getX() < 5 && value[ 0 ] != 3 ) 19 cerr displayError(); 20 ]]> 21 22 23 C++ How to Program by Deitel & Deitel 24

15 CDATA Example (cont'd)

16 Namespaces 1 2 3 4 5 6<directory xmlns:text = "urn:deitel:textInfo" 7 xmlns:image = "urn:deitel:imageInfo"> 8 9 10 A book list 11 12 13 14 A funny picture 15 16 17 18

17 Default Namespaces 1 2 3 4 5 6<directory xmlns = "urn:deitel:textInfo" 7 xmlns:image = "urn:deitel:imageInfo"> 8 9 10 A book list 11 12 13 14 A funny picture 15 16 17 18


Download ppt "Unit 8 XML Documents. Key Concepts XML fundamentals XML document format Document declaration XML elements and attributes Parsing Characters and white."

Similar presentations


Ads by Google