Home > SOA Tips > .NET Developer > The VB DOMDocument class
SOA Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

.NET DEVELOPER

The VB DOMDocument class


Rod Stephens
10.15.2002
Rating: --- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



.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 methods. 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.

Dim xml_document As New DOMDocument

  xml_document.loadXML _
    "<Person>" & vbCrLf & _
    "  <FirstName>Rod</FirstName>" & vbCrLf & _
    "  <LastName>Stephens</LastName>" & vbCrLf & _
    "</Person>"

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:

  • Looking for free research? Browse our comprehensive White Papers section by topic, author or keyword.
  • Are you tired of technospeak? The Web Services Advisor column uses plain talk without the hype.
  • For insightful opinion and commentary from today's industry leaders, read our Guest Commentary columns.
  • Hey Codeheads! Start benefiting from other time-saving XML Developer Tips and .NET Developer Tips.
  • Visit our huge Best Web Links for Web Services collection for the freshest editor-selected resources.
  • Choking on the alphabet soup of industry acronyms? Visit our helpful Glossary for the latest lingo.
  • Visit Ask the Experts for answers to your Web services, SOAP, WSDL, XML, .NET, Java and EAI questions.
  • Discuss this issue, voice your opinion or just talk with your peers in the SearchWebServices Discussion Forums.

Rate this Tip
To rate tips, you must be a member of SearchSOA.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Platforms and Servers
Tracking down managed memory leaks
Handling exceptions in .NET
.NET Compact Framework graphics
The Data Access Application Block
Decision time: .NET or J2EE?
A great .NET resource: .Net2TheMax
Delegates vs. interfaces in .NET
Project structure best practices
Working with PDFs in a .NET environment
Displaying errors with the error provider

Microsoft .NET Web services
Microsoft preps .NET 4.0 - framework improves on REST, MVC, JQuery support
How do I balance throughput requirements and interoperability?
APM software traces transactions across tiers, technologies
How you can learn M Grammar for Oslo modeling
Legacy modernization opens Windows for publisher
Former .NET Web developers ride Ruby and Rails application framework
Microsoft Oslo at PDC: Dial 'M' for modeling language
Yahoo proxy fight looms
New Microsoft site for architects
LAMP coders go hybrid route
Microsoft .NET Web services Research

.NET Developer
Programming Indigo
DataSets and Web services don't mix
Security in .NET 2.0
Tracking down managed memory leaks
Handling exceptions in .NET
.NET Compact Framework graphics
The Data Access Application Block
A great .NET resource: .Net2TheMax
Delegates vs. interfaces in .NET
Project structure best practices

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
Common Language Infrastructure  (SearchSOA.com)
Visual J#  (SearchSOA.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



SOA Trends and Strategy - SOA Education, SOA Development, SOA Implementations
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2001 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts