Sams Teach Yourself XML in 21 Days

Sams Teach Yourself XML in 21 Days

By Steven Holzner

Part I. In Review

In Part I, which is all about creating XML documents, you got the basics, including how to write XML documents, how to create well-formed documents, and how to make sure XML documents are valid. You saw that there can be various parts in an XML document, not all of which must appear in all documents:

For example, this XML document, which holds the names of clients for whom you might be doing some programming, begins with an XML declaration, and the document element is <document>:

<?xml version = "1.0" standalone="yes"?>
<document>
    <client>
        <name>
            <lastname>Kirk</lastname>
            <firstname>James</firstname>
        </name>
        <contractDate>September 5, 2092</contractDate>
        <contracts>
            <contract>
                <app>Comm</app>
                <id>111</id>
                <fee>$111.00</fee>
            </contract>
            <contract>
                <app>Accounting</app>
                <id>222</id>
                <fee>$989.00</fee>
            </contract>
        </contracts>
    </client>
    <client>
        <name>
            <lastname>McCoy</lastname>
            <firstname>Leonard</firstname>
        </name>
        <contractDate>September 7, 2092</contractDate>
        <contracts>
            <contract>
                <app>Stocker</app>
                <id>333</id>
                <fee>$2995.00</fee>
            </contract>
            <contract>
                <app>Dialer</app>
                <id>444</id>
                <fee>$200.00</fee>
            </contract>
        </contracts>
    </client>
    <client>
        <name>
            <lastname>Spock</lastname>
            <firstname>Mr.</firstname>
        </name>
        <contractDate>September 9, 2092</contractDate>
        <contracts>
            <contract>
                <app>WinHook</app>
                <id>555</id>
                <fee>$129.00</fee>
            </contract>
            <contract>
                <app>MouseApp</app>
                <id>666</id>
                <fee>$25.00</fee>
            </contract>
        </contracts>
    </client>
</document>

Each element here has an opening and closing tag, and each element is nested properly.

Share ThisShare This

Informit Network