O'Reilly logo

Professional XML by Michael Kay, Kent Sharkey, Sam Ferguson, Alessandro Vernet, Bill Evjen, Thiru Thangarathinam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 12. XML Document Object Model (DOM)

XML was introduced to alleviate interoperability problems across platforms and networks. A standard language, combined with a DTD (or another schema construct), provides a way of exchanging data. Not only does data need to be in a standard format, but the way data is accessed should also be standardized. XML provides the constructs for putting data into a standard format, and as you will soon see, the Document Object Model provides a standard way of accessing data. A Web developer, who provides some script inside a Web page that makes use of an XML document, shouldn't have to recode the script to work in every browser. This chapter takes you through a tour of the XML DOM features, including its object model, various classes, and their usage. Specifically you will see:

  • The need for XML DOM processing on the client side

  • The different classes contained in the XML DOM

  • How to work with the various classes of XML DOM

  • How to create, read, and modify nodes in an XML document

  • How to validate an XML document against an XSD schema using XML DOM

  • How to transform an XML document into HTML using XML DOM

What Is DOM?

Some overhead is involved when using XML documents, because extracting data from the tags in an XML document can be arduous. A parser is used to take care of checking a document's validity and extracting the data from the XML syntax. A layer of abstraction between the application and the XML document is made possible by the XML Document Object Model ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required