This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > Microsoft XML > October 2005 > Constructing an XML Tree Using the DOM
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Constructing an XML Tree Using the DOM
|
|
| Sam Hobbs 2005-10-27, 6:28 pm |
| I am "Constructing an XML Tree Using the DOM" except I have to save it to
disk to get it to work.
I am creating the XML in a manner similar to:
Getting the XML Data
http://msdn.microsoft.com/library/d...e07acf5d462.asp
Except I am using VB6 without HTML. I am building the XML to be shown in a
Datagrid control in a VB form. It works, except only if I save the XML to
disk then load it back into the same XML document object. The document
object is a DOMDocument object.
Is there something I am supposed to do to close or complete the document so
that it works without saving it to disk?
The following is a summary of what I do.
Dim XML_Document As DOMDocument
Dim DataSource As New DSOControl
Set XML_Document = DataSource.XMLDocument
Set Node = XML_Document.createNode(NODE_ELEMENT, "Descriptor", "")
XML_Document.appendChild Node
Then I do multiple iterations of:
Set EntryNode = XML_Document.createNode(NODE_ELEMENT, "Entry", "")
XML_Document.documentElement.appendChild EntryNode
Set Node = XML_Document.createNode(NODE_ELEMENT, "Mask", "")
Node.Text = Mask
EntryNode.appendChild Node
Set Node = XML_Document.createNode(NODE_ELEMENT, "Type", "")
Node.Text = Type
EntryNode.appendChild Node
| |
| Sam Hobbs 2005-10-27, 10:18 pm |
| I should add a little more to what I said.
First, the reason I saved the XML to a file is to see what got created, for
diagnostic purposes. So that line of code is:
XML_Document.save App.Path & "\Descriptor.xml"
Then in order to debug, I used a simpler version of my code, so for that I
just loaded the XML from the file I had saved to. Then when the code that
worked in the simpler version did not work in the full version of my
program, I tried loading the XML back in. Without loading the XML back in,
the DataGrid has a single row and a single column, and all the data exists
in that single cell. Most of the explanation of why that happens is probably
due to the way that the XML DSO works, but I am asking if there is something
that I need to do with the XML If I simply add the following two lines after
the save, then I get the rows and columns that I want. Actually, I get an
extra column, but that is off-topic for this newsgroup. Note that the object
I load into is the exact same object I save from.
XML_Document.async = False
XML_Document.Load App.Path & "\Descriptor.xml"
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|