The XML Document Object Model

You can create, access, and manipulate XML documents programmatically via the XML DOM (Document Object Model). The DOM has properties, methods, and constants for interacting with XML documents. The XML DOM is supplied with Internet Explorer. To use the XML DOM from your VBA procedures, you need to set up a reference to the MSXML object library. To do this, switch to the Visual Basic Editor window and choose Tools | References. In the References dialog box, locate and select Microsoft XML, v3.0 (see Figure 17-23). If you are using Microsoft Internet Explorer 4.0, you'll need to choose the version 2.0 type library (or upgrade your browser to the higher version). Now that you have the reference set, you can open the Object Browser and examine XML DOM's objects, methods, and properties (see Figure 17-24).

Figure 17-23:

To work with XML documents programmatically, you need to establish a reference to the Microsoft XML type library.

Figure 17-23:

To work with XML documents programmatically, you need to establish a reference to the Microsoft XML type library.

The DOMDocument object is the top level of the XML DOM hierarchy. This object represents a tree structure composed of nodes. You can navigate through this tree structure and manipulate the data contained in the nodes by using various methods and properties. The DOMDocument object is the parent for all other elements in the DOM hierarchy. Because every XML object is created and accessed from the document, the DOMDocu-ment object must be created first.

Object Browser

3

I'mSXMLZ :! I !

1 \x\

1 dfc

Classes

Mâ rnbere of globalst"

<äJ NOD EjA.TTR!0UTE

DOMDocument

a NODE_CDATA_SECTION

tffi DOMDacument26

<H NODE_COMMEMT

¿5 DOMDocument30

iXl NOD E_D OCUMÉNT

Dsocontrai

S NODE_DQCUMENT_FRAOMENT

OSOCont™i26

BJ NODE_DOCUMENT_TVPE

DSOContr:l3Q

LU NODE_ELEMENT

tfS FreeThreadsdDOMDocumenl

LËI NODE_ENTITY

¿5 FreeTmeadedDQMDocuinent26

© NODE_EMTTY_REFERENCE

S3 FreeTmeadedDQMDocumenoo

S3 NODEJNWLID

IMXReaderCorrtral

O WODE.NOTATION

IVBSAXAtiriCute £

dl MODE_PROCESSINOJNSTRUCT1 ON

ÈS IVBSAXContenlH andi er

LÜ NODErJEXT

&J- iVBSWDsclHanüler

(3 XMLE LEMTYPE_COMM E NT

M iVBSAXtiTDHantiler_W

¿J KMLE LEMTVPE_OOCUMENT

zi

Library MSXML2 C:WJNnsystem32'irexirJ3.oli Microsoft XML, v3Q

0 0

Post a comment