Академический Документы
Профессиональный Документы
Культура Документы
Objectives
In this lesson, you will learn to:
☛ Identify the need for XML Document Object Model
(DOM)
☛ Use the following XML DOM objects to access
different parts of an XML document:
✓ DOMDocument
✓ IXMLDOMNode
✓ IXMLDOMNodeList
✓ IXMLDOMParseError
myxmldoc.load("c:\examples\employees.xml
");
myroot=myxmldoc.createNode(1,"ORDERDETAI
LS"," ");
myxmldoc.appendChild(myroot);
myxmldoc.save(myxmldoc.XMLDocument);
}
©NIIT eXtensible Markup Language/Lesson 7/Slide 19 of 43
Working with the XML Document Object Model
myxmldoc.documentElement.childNodes.item
(1).insertBefore(newElement,
oldElement);
©NIIT eXtensible Markup Language/Lesson 7/Slide 27 of 43
Working with the XML Document Object Model
myxmldoc.documentElement.childNodes.ite
m(0).RemoveChild(oldElement);
Task List
☛ Identify a mechanism to access an XML document
programmatically.
☛ Identify the objects required to access the XML
document.
☛ Write the code to access the document.
☛ Execute the code.
Just a Minute…
☛ The details about products sold at CyberShoppe are
stored in an XML document called product.xml. Write
the code to display the price of all products by using
DOM objects.
Summary
In this lesson, you learned that:
☛ DOM is an application programming interface that
enables an application to access the contents of an
XML document.
☛ DOM objects enable you to access and manipulate
XML documents.
☛ When the MSXML parser loads an XML document, it
creates a tree structure that represents the various
components of the XML document.
Summary (Contd.)
☛ The basic building block of the tree structure is a
node. A node is a container that holds information
about the elements, attributes, and content stored in
an XML document.
☛ Some XML DOM objects that are used to manipulate
data in a document are:
✓ DOMDocument
✓ IXMLDOMNode
✓ IXMLDOMNodeList
✓ IXMLDOMParseError
Summary (Contd.)
☛ The DOMDocument object is the top-level object in
XML DOM. This object provides various properties
and methods that help you to navigate, query, and
modify the content and structure of XML documents.
☛ The IXMLDOMNode object represents a node in the
XML document structure. This object provides
methods to work with child elements.
☛ The IXMLDOMNodeList object enables you to iterate
through a collection of nodes.
☛ The IXMLDOMParseError object returns information
about the most recent error.