Microsoft Xml Dom Download For Mac

Visual Basic and the XML DOM: An Annotated Example

July 12, 2000

Mark Wilson and Tracey Wilson

In the Import Data dialog box, do one of the following. XML table in existing worksheet The contents of the file are imported into a new XML table in a new worksheet.If the XML data file doesn't refer to a schema, Excel infers the schema from the XML data file. Existing worksheet The XML data is imported in a two-dimensional table with rows and columns that shows XML tags as column headings. The XML viewer softwares are available for all major operating system like Microsoft Windows, MAC and Linux. If you do not wish to install the XML viewer software you can also opt for XML viewer online, that help you in viewing, editing, validating and exporting files on the internet itself.

  • The XML viewer softwares are available for all major operating system like Microsoft Windows, MAC and Linux. If you do not wish to install the XML viewer software you can also opt for XML viewer online, that help you in viewing, editing, validating and exporting files on the internet itself.
  • Xml free download - XML Viewer, DriveImage XML, Free XML Editor, and many more programs.
Table of Contents

•XML DOM Basics
•Our Example Program
•Running the Example
•Source XML Document
•Module Variables
•Populating the TreeView from the DOMDocument
•The populateTreeWithChildren Subroutine
•Populating the Text Boxes from the DOMDocument
•Adding a New Person to the DOMDocument
•Deleting a Person from the DOMDocument
•Conclusion

One of the most frequently asked questions we get concerning XML and Visual Basic is about how to work with the Microsoft XML Parser (MSXML.DLL) that comes with Internet Explorer 5. It's fine knowing how to write XML, but one needs to know how to read and manipulate an XML file.

This article takes us through an annotated example of how to use the Microsoft XML Document Object Model (DOM) parser to load a TreeView control in Visual Basic. (Populating a TreeView is a good example, as XML documents themselves are tree-structured.) From there we then go on to explain how to manipulate an XML document by adding and deleting data items.

This article is based on a section of the book 'XML Programming with VB and ASP' (Manning Publications) by Mark Wilson and Tracey Wilson. This is an extract from Chapter 4, Section 9.

XML DOM Basics

The DOM consists of several interfaces. Every object in the DOM is called a 'node,' whether it's an element, attribute, CDATA section, comment, or processing instruction.

The DOMDocument object will contain our XML document. From there, we access our XML data via the DOMDocument's documentElement property, which is available from the IXMLDOMElement or IXMLDOMNode interface.

These interfaces have a childNodes property, which is how we iterate through each of the 'child' elements, comments, etc., of the parent node. The IXMLDOMNodeList interface allows us to access a collection of nodes, such as the children of an element.

The following diagram shows the hierarchy of these interfaces. Note that only the most common interfaces are shown below:

Figure 1: MSXML DOMDocument Interfaces

Our Example Program

Working back-to-front, here's what we're aiming for:

Figure 2: DOM Example screenshot

Clicking on the 'Populate People' command button loads and displays the content of an XML 'People' document. As you click on each person in the TreeView, the text box contents on the right-hand side will show details relating to the element you click, using the DOM object to get the details.

We've included a web-browser control to the form, so that you can see the changes happening to the XML file as you add and delete elements. To add a new person, click on the 'Clear Items for new Person' button. Add your details to the text boxes. Then click on the 'Save New Person' button. This creates the new 'PERSON' element and adds it to the XML document.

To delete a person, click on a person in the TreeView. Then click on the 'Delete Person' button, which will automatically delete the selected person, removing him/her from the TreeView, DOM Object, and the actual XML file.

Running the Example

To run this project, download the source code, then

  • copy the contents of the downloaded zip into a directory,
  • make sure that you have the 'Microsoft XML 2.0' dll installed, and
  • run the DOMExample.vbp.

One word of caution before we examine the code: because the DOMDocument and the TreeView use the term 'node' for specifying their objects, we've tried to explicitly differentiate between the two in our comments.

Right, let's dig into the code!

Source XML Document

The following XML document has been used for this example:

Module Variables

These global variables go into the General Declarations of the project:

Populating the TreeView from the DOMDocument

When the user clicks on the 'Populate People' button, the following code populates the TreeView with the contents of the DOMDocument:

ResolveExternals prevents the m_objDOMPeople object from looking for external files--which in our case is the people2.dtd. Set this to true if you want the parser to find the external files.

ValidateOnParse can stop the m_objDOMPeople from validating the XML file against the people.dtd file--set this to true if you want validation to occur.

The XML file first needs to be loaded into the DOMDocument (m_objDOMPeople). We need to load the file synchronously to instruct that the XML file will be completed loaded into the DOM, when loading; therefore we set the async property to false.

Check that the load of the XML document was successful.

There has been an error with the loaded XML--show the reason.

Get to the root element of the XML document--bypassing the comments, PIs, etc.

Once we have obtained the root element (documentElement) of the DOMDocument, we can start working with the data from the XML file. The first thing we want to add to the TreeView is the name of the root element of the XML file, which is 'PEOPLE'. Then we need to start adding child nodes.

Set the TreeView control properties.

Check if the TreeView has already been populated: if so, remove the root, which removes everything.

Add a child to the root node of the TreeView.

Now all we need to do is iterate through these childNodes of the DOMDocument's 'PEOPLE' elements, which is going to return five 'PERSON' elements. This is done by the 'For Each' loop, which leads us to the code in populateTreeWithChildren method.

Iterate through each 'PERSON' element in the DOM to fill the tree, which in itself iterates through each childNode of that element (objPersonElement) to drill down into its childNodes.

The populateTreeWithChildren Subroutine

This code is called from the cmdPopulate click event. For each parent node created on the TreeView, drill down into the DOM Element that has been passed in and populate the TreeView with these DOMElement childNodes.

The parameter, objDOMNode, is the current child node from the docElement property of the DOMDocument.

We need to add a title to the current TreeView node, by adding the element's main child node ('NAME') as the heading for the TreeView of this section. We use the method selectSingleNode to return the first node that it finds with the nodeName of 'NAME'.

Add the 'NAME' element's parent node nodeName and its value to the TreeView.

Add the ID of the node to the TreeView node's tag property. The element node holds the ID attribute that we want to store in the tag, as an identity reference. We therefore need to get hold of this node to get its value.

We know that we've named our ID reference as 'PERSONID', therefore we ask the NameNodeListMap to get this node by using the getNamedItem method. But firstly, we need to check if there are attributes:

Store this value in the tag of the TreeView.

We then need to populate the current TreeView node from the current DOM element node (objDOMNode) by once again iterating through the childNodes of the objDOMNode.

This completes our population of the TreeView from the DOMDocument.

Populating the Text Boxes from the DOMDocument

When the user clicks on the TreeView, we need to fetch data from the DOMDocument to populate the text boxes on the right-hand side of the screen.

A little bit of VB checking for unwanted event firing--if this code has just come from the expand and collapse event, then ignore it.

Call the procedure that handles populating the text boxes.

This procedure populates the form's text boxes with details from the passed Node object (objSelNode). The parameter objSelNode is the current TreeView node, which the user has clicked on.

Ignore this TreeView selection if it has not been the 'PERSON' node that has been clicked on:

We need to find the node in the DOMDocument that corresponds to the TreeView item the user has clicked:

With this found node (objPersonElement), once again we are going to iterate through its childNodes to populate the text boxes, by using a 'Select Case' to filter which element we are dealing with.

Check that the type of node you are dealing with is an element node, as it could also be other types of nodes, for example PIs. Then populate the text box with the text from the DOM node.

Clear the object memory resources.

Adding a New Person to the DOMDocument

Here the user will fill the text boxes on the right-hand side with the details for the new person: these then need to be saved to the DOMDocument.

Download game bully ps2 for android. This is done in two parts: firstly, clearing all the text boxes, then saving the content. We know this is not 'cool' coding but it's just for ease of coding to show the basics of working with the DOMDocument.

This clears the contents of the text boxes.

After filling in the text boxes, the user clicks on the 'Save New Person', which fires cmdAdd to save the new 'Person' to the DOMDocument.

This method creates a new element from the user input, and adds it and its children to the DOM object.

Firstly we need to create a new 'PERSON' child node (objPerson) for the documentElement node ('PEOPLE').

Before continuing, we also need to give this 'PERSON' node a 'PERSONID' attribute--here we use our getNewID method to return this ID string. We need to do this as the attribute has been set up as 'required' in the DTD. We use the setAttribute method to set this attribute value and add the attribute to the element node.

To this new 'PERSON' child we must add its childNodes ('NAME', 'ADDRESS', etc). We have chosen to use the createElement method to add the childNodes. However, you can choose to use the createNode method; which you use is just a matter of preference.

Each childNode needs to be appended to the current 'PERSON' node.

We reuse the populateTreeWithChildren method to keep the TreeView in sync with the changes to the DOMDocument.

Microsoft Xml Dom Download For Mac Windows 10

The new element may be added to the DOMDocument, but it is not added to the source XML until you save the document.

Deleting a Person from the DOMDocument

Clicking the 'Delete' button allows the user to delete a node from the DOMDocument.

The following code deletes the selected TreeView view node, as well as the corresponding item from the DOMDocument. The parameter objSelNode is the TreeView node that has been clicked on.

If no tree node has been selected, then exit the procedure.

Once again, we need to find the ID stored in the selected TreeView node, or its parent node tag property, to be able to delete it.

Once we have found this ID, use the nodeFromID method of the DOMDocument to return the DOMDocument node that needs to be deleted. Find the DOMDocument node, using the tag value found in the selected node of TreeView tag property.

If the DOMDocument node exists, use the removeChild method that can be accessed via the DOMDocument's documentElement property.

We need to save the DOMDocument, to reflect the removal of the childNode. The TreeView also needs to be kept in sync with this deletion.

Conclusion

In this example, techniques for working with the DOMDocument covered included the following:

  • The fundamentals of loading an XML document into your program
  • What to watch out for when you're using a DTD or Schema to validate your document
  • Populating a TreeView control with the same hierarchy found in the DOMDocument
  • When clicking on the TreeView control, how to find an item in the DOMDocument, based on a value stored in the tag of the selected TreeView item
  • How to add a new item to an XML file, using the createElement and appendChild methods
  • How to delete an item from the XML file, using the removeChild method
  • How to save the document using the save method after making changes in the DOMDocument

Microsoft Xml Dom Download For Mac Windows 10

Here are a few suggestions for expanding the application, and hints on doing a bit of experimentation to broaden your knowledge of working with the DOM:

  • Update the document when the user has changed an item.
  • In the populateTreeWithChildren procedure, we have specifically shown you how to use the IXMLDOMNamedNodeMap interface for iterating through attributes. You can change this procedure to use the getAttributeNode or getAttribute methods.
  • In the section, 'Adding a New Person to the DOMDocument,' instead of using setAttribute for adding an attribute to the element, have a look at using the createAttribute method on the DOMDocument object and then using the setNamedItem method to add it to its element's attribute property.

For more information on using XML and Visual Basic visit VBXML.com, run by the authors of this article.

Copyright 1999 Manning Publications Company. Reprinted with permission.

Download EditiX XML Editor and test it for free for 30 days for commercial usage.

Version : 18.0
Build : 020121
Evaluation : 30 days(5 days for previous usage)

Microsoft Xml Dom Download For Mac Windows 7


Release information


Binaries - Professional 2021 Edition


Platform

Windows (2000/XP/Vista/7/8/10) - 32 bitsDownload (102 Mb)
Windows (2000/XP/Vista/7/8/10) - 64 bitsDownload (107 Mb)
Mac/Unix/Linux/ZIPDownload (56 Mb)
Mac OS X/DMGDownload (107Mb)
Mac OS X/ZIPDownload (56 Mb)


Open Source GIT directory - Community 2017 Edition

Comparison Professional / Community

FeatureCommunityProfessional
XML Editor (content assistant, validation..)xx
XSLT Editor basicxx
XSLT Editor enhancedx
W3C Schema Editorx
ZIP Browserx
XML Data basex
JavaScript Editorx
HTML/XHTML Editorx
XML Diffx
JSON Editorx
Regular updatex

Installation instructions :

Microsoft Xml Dom Download For Mac Download

For Windows

Games Download For Mac

The default install contains a Java VM version. Windows may complain when running because a Java VM will be installed, it may require an administrator privilege before installing.

If you want to install yourself a Java VM, you need at least a Java VM 8. Then you may download the ZIP version and run editix only from the bin/editix.bat command.

For Mac/Unix/Linux

You need at least a Java VM 8.x. You may download it from this page. Open a terminal/console and use 'java -version' for checking your current version.

Mac OS X / ZIP, here the steps.

Note : OpenJDK has too many bugs for running editix, use official Java VM from oracle.

Mac OS X / DMG, you may have a message the file is corrupted. This is due to a security from Mac OS X for application outside the APPStore.

- Go to Apple menu > System Preferences, and then click on the Security & Privacy icon.

  • - Under the General tab, look in the setting for “Allow apps downloaded from” and you should see that the app you tried to open was noticed by the operating system. Click the Open Anyway button to open that new app.

Note for Mac OS Sierra (>v13) : You must use the ZIP version

Xml Dom Document Add On

For Running from the command line

From the bin directory :

editix.sh* : Starting EditiX for a unix/linux and mac os x platform

editix.bat : Starting EditiX for a windows platform.

scenario.sh* : Running a scenario for a unix/linux and mac os x platform.

scenario.bat : Running a scenario for a windows platform.

* Use the command chmod u+x scriptname make the script executable or inside your window manager changing the permission to 'execute'.

For the Community 2017 Edition

git clone https://github.com/AlexandreBrillant/Editix-xml-editor

You need a Java VM (JDK for compiling) and Ant.

Uninstalling instructions :

The following procedure will remove EditiX XML Editor from your system. Be sure that all valuable data stored in the install folder is saved to another location.

  • - On Windows use the appropriate uninstaller shortcut
  • - On Mac OS X and Unix manually delete the installation folder and all its contents

For removing all the editix's preferences, please delete the directory YOUR_HOME_DIRECTORY/.editix

Download older versions

Download EditiX XML Editor 2018
Download EditiX XML Editor 2017