|
-
Jul 15th, 2002, 05:19 PM
#1
Thread Starter
Junior Member
XML and VB6.0
I am just trying to get to grips with XML using the DOMDocument and related objects in Visual Basic 6.0
I've managed to create an XML document based on a recordset returned from an Access database using ADO.
I cycle thru the recordset adding the records using the various append methods and then call xmlDoc.Save. My xml document ends up in the form...
<data>
<record ID="1" LName="Hobson" FName="Graham"</record>
<record ID="2" LName="Smith" FName="John"</record>
</data>
I have two questions: -
1. How do I get the <?xml version="1.0"?> line to appear at the beginning of the file as it always is in the help file examples.
2. When I open the file in IExplorer the layout is as above (OK). However when I open it in Notepad (for instance to edit directly) the file is not layed out like this but is one long textstream i.e.
<data><record ID="1" LName="Hobson" Name="Graham"</record><record ID="2" LName="Smith" FName="John"</record></data>
When I open other XML files in Notepad they have the same alyout as the IExplorer version. Why is this?
If anyone can help I would be grateful. Thanks.
PS The first example is indented at the record level but I don't think it displays correctly on here.
-
Aug 20th, 2003, 01:23 PM
#2
Member
I got this code from the MSXML4.0 SDK.
Question 1:
VB Code:
' Create a processing instruction targeted for xml.
Set node = dom.createProcessingInstruction("xml", "version='1.0'")
dom.appendChild node
Set node = Nothing
' Create a processing instruction targeted for xml-stylesheet.
Set node = dom.createProcessingInstruction("xml-stylesheet", _
"type='text/xsl' href='test.xsl'")
dom.appendChild node
Set node = Nothing
' Create a comment for the document.
Set node = dom.createComment("sample xml file created using XML DOM object.")
dom.appendChild node
Set node = Nothing
Question 2:
VB Code:
' Insert a newline + tab.
root.appendChild dom.createTextNode(vbNewLine + vbTab)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|