.NET Developer Tip
(Receive this column in your inbox,
click Edit your Profile to subscribe.)
The VB DOMDocument class
Rod Stephens
This tip, excerpted from InformIT, offers some information on one class that provides a few really useful properties and methods.
Visual Basic.NET provides integrated tools for using XML, schemas, XSL, and other XML-related tools, but there's no need to wait for VB.NET in order to get started. Microsoft XML Core Services (MSXML) version 4.0 gives you the tools you need to load and save XML documents from your Visual Basic 6 application.
Download the most recent version of MSXML at msdn.microsoft.com/xml/default.asp, and install it on your computer. To use MSXML in a Visual Basic 6 program, select the Project menu's References command. Select Microsoft XML, v 4.0 (or whatever the version du jour is), and click OK. Now you're ready to add XML objects to your program.
DOMDocument Class
The DOM (document object model) describes an XML file's hierarchical nature using a corresponding set of programming objects. DOMDocument is the MSXML class that represents an XML document's DOM structure.
The DOMDocument class provides only a few really useful properties and m
To continue reading for free, register below or login
To read more you must become a member of SearchSOA.com
');
// -->

ethods. The load method makes the object load an XML file. The loadXML method makes it load XML data from a string. For example, the following code loads a small XML file into the document named xml_document.
The DOMDocument's xml property returns the document's XML representation. You can display this value to see what the document looks like. You could also save it into a file, but there's really no need to do that because the DOMDocument object's save method does it automatically.
The object's documentElement property is a node that represents the document's topmost data node. All the other nodes lie within that one. Usually, when you manipulate an XML document's nodes, you will start at this node.
DOMDocument provides several methods for creating new nodes. The createElement method makes a new element node for the document. This is the kind of node you usually want to create. Other node creation methods include createAttribute, createProcessingInstruction, and createTextNode, although I won't say anything about those methods in this article.
To read the article from which this tip is excerpted, click over to InformIT. You have to register there, but the registration is free.
For More Information: