Chapter 24

XML


Chapter Goals

XML

XML Encoding of Coin Data

<coin>
   <value>0.5</value>
   <name>half dollar</name>
</coin>

Advantages of XML

Differences Between XML and HTML

Differences Between XML and HTML

Structure of an XML Document

Structure of an XML Document

Structure of an XML Document

Parsing XML Documents

Parsing XML Documents

JAXP

Parsing XML Documents

Parsing XML Documents

Parsing XML Documents

An XML Document

<?xml version="1.0"?>
<items> <item> <product> <description>Ink Jet Refill Kit</description> <price>29.95</price> </product> <quantity>8</quantity> </item> <item> <product> <description>4-port Mini Hub</description> <price>19.95</price> </product> <quantity>4</quantity> </item> </items>

Tree View of XML Document

Tree View of XML Document

Parsing XML Documents

Parsing XML Documents

Parsing XML Documents

File ItemListParser.java

File ItemListParserTest.java

Creating XML Documents

Creating XML Documents

Creating XML Documents

Creating XML Documents

An XML Tree that Describes a Product

An XML Tree that Describes a Product

File ItemListBuilder.java

File ItemListBuilderTest.java

Document Type Definitions

Document Type Definitions

Encodings for Special Characters

Encodings for Special Characters

DTD for Item List

<!ELEMENT items (item)*>
<!ELEMENT item (product, quantity)>
<!ELEMENT product (description, price)>
<!ELEMENT quantity (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT price (#PCDATA)>

Regular Expressions for Element Content

Regular Expressions for Element Content

Document Type Definitions

Common Attribute Types

A Table of Common Attribute Types

Attribute Defaults

Table of Attribute Defaults

Document Type Definitions

Parsing with Document Type Definitions

Parsing with Document Type Definitions

Parsing with Document Type Definitions

Parsing with Document Type Definitions

Parsing with Document Type Definitions

Parsing with Document Type Definitions

File ItemListParser.java

File ItemListParserTest.java