dom - Document Object Model Copyright 1999 - 2010 Ellis...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Copyright © 1999 - 2010 Ellis Horowitz DOM 1 Document Object Model
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Copyright © 1999 - 2010 Ellis Horowitz DOM 2 What is DOM • The Document Object Model (DOM) is a programming interface for XML documents. – It defines the way an XML document can be accessed and manipulated – this includes HTML documents • The XML DOM is designed to be used with any programming language and any operating system. • The DOM represents an XML file as a tree – The documentElement is the top-level of the tree. This element has one or many childNodes that represent the branches of the tree.
Background image of page 2
Copyright © 1999 - 2010 Ellis Horowitz DOM 3 Version History DOM Level 1 concentrates on HTML and XML document models. It contains functionality for document navigation and manipulation. See: http://www.w3.org/DOM/ DOM Level 2 adds a stylesheet object model to DOM Level 1, defines functionality for manipulating the style information attached to a document, and defines an event model and provides support for XML namespaces. The DOM Level 2 specification is a released W3C Recommendation, see: http://www.w3.org/TR/DOM-Level-2-Core/ DOM Level 3 consists of 6 different specifications DOM Level 3 Core, http://www.w3.org/TR/DOM-Level-3-Core/ DOM Level 3 Load and Save, http://www.w3.org/TR/DOM-Level-3-LS/ • Allows loading content of XML document into a DOM document DOM Level 3 XPath, http://www.w3.org/TR/DOM-Level-3-XPath/ • Functionality to access a DOM tree using XPath DOM Level 3 Views and Formatting, http://www.w3.org/TR/DOM- Level-3-Views/ DOM Level 3 Requirements, http://www.w3.org/TR/DOM-Requirements/ DOM Level 3 Validation, http://www.w3.org/TR/DOM-Level-3-Val/ • Allows programs and scripts to dynamically update the content and structure of documents
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Copyright © 1999 - 2010 Ellis Horowitz DOM 4 HTML or XML files viewed as a tree - order.xml <order id="100" date="20033112"> <customer> <name>S Spade</name> <address>123 main st</address> <city>Brooklyn</city> <zip>10012</zip> </customer> <orderitem id="A1002" quantity="1"/> <orderitem id="A1007" quantity="2"/> </order> order.xml <order> id date Document Root Attributes <orderitem> id quantity <customer> <name> <address> <city> <zip> nodelist DOM represents documents as a hierarchy of node objects Some types of nodes have children
Background image of page 4
DOM 5 Some Useful DOM Functions document is the root element document.getElementById("sample") Returns the one location defined by id=sample, e.g. document.getElementById("sample").style.color="rgb(“FF",“FF",“00"); document.getElementsByTagName("font") – returns ALL font elements, e.g. arrayOfDocFonts = document.getElementsByTagName("font"); innerHTML – assigns a new value to text defined by id=counter2 document.getElementById("counter2").innerHTML = "Number of clicks = 1"; style.left, style.color properties – one can assign to CSS properties, e.g. document.getElementById('counter1').style.left = '500px';
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 49

dom - Document Object Model Copyright 1999 - 2010 Ellis...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online