|
-
Aug 25th, 2009, 04:02 PM
#1
Thread Starter
Addicted Member
[RESOLVED] XML Data Types and VB6
Hello,
I am creating an XML file and I need to have data types defined in the section.
Here is my code. How do I set datatypes for the XML File?
Code:
Dim xmlDoc As MSXML2.DOMDocument
Dim xmlProcess As MSXML2.IXMLDOMProcessingInstruction
Dim xmlObjSubData As IXMLDOMNode
Dim xmlObjCycle As IXMLDOMNode
Dim xmlObjCU As IXMLDOMNode
Dim xmlObjDetails As IXMLDOMNode
Dim lstrXMLFile As String
Set xmlDoc = New MSXML2.DOMDocument
lstrXMLFile = myxmlfile.xml
If Dir(lstrXMLFile) <> "" Then
Call KillFile(lstrXMLFile) 'this kills the file to start over....
End If
Set xmlProcess = xmlDoc.createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'")
xmlDoc.appendChild xmlProcess
'create root node
Set xmlObjSubData = xmlDoc.createElement("SubmissionData")
xmlDoc.appendChild xmlObjSubData
xmlObjSubData.appendChild xmlObjSubData.ownerDocument.createTextNode(vbCrLf + Space$(5))
Set xmlObjCycle = xmlDoc.createElement("Cycle")
xmlObjSubData.appendChild xmlObjCycle
xmlObjCycle.appendChild xmlObjCycle.ownerDocument.createTextNode(vbCrLf + Space$(10))
Set xmlObjDetails = xmlDoc.createElement("Month")
xmlObjDetails.text = Left$(Parm5300.mstrCycleDate, 2)
xmlObjDetails.dataType = "string"
xmlObjCycle.appendChild xmlObjDetails
xmlObjCycle.appendChild xmlObjCycle.ownerDocument.createTextNode(vbCrLf + Space$(10))
Set xmlObjDetails = xmlDoc.createElement("Year")
xmlObjDetails.text = Right$(Parm5300.mstrCycleDate, 4)
xmlObjDetails.dataType = "String"
xmlObjCycle.appendChild xmlObjDetails
xmlObjCycle.appendChild xmlObjCycle.ownerDocument.createTextNode(vbCrLf + Space$(5))
Set xmlObjCycle = Nothing 'not sure how to end the cycle...
Any help would be appreciated.
Thanks
Dave
-
Aug 25th, 2009, 04:14 PM
#2
Re: XML Data Types and VB6
not sure what you mean... can you post an example of what you're looking for?
EDIT - never mind, I see the highlighted code there... but I'm still not sure what you mean exactly... xml is essentially type-less... you have nodes. Nodes have values. You have attributes, attributes have values. they are what they are.
-tg
-
Aug 26th, 2009, 12:26 AM
#3
Re: XML Data Types and VB6
Here's something I happen to be working on. It's a fragment at this point but it works as far as it has been completed and has an example of what I think you want:
Code:
Public Property Get XML() As String
Dim DOM As MSXML2.DOMDocument40
Dim ATTR As MSXML2.IXMLDOMAttribute
Set DOM = New MSXML2.DOMDocument40
With DOM.appendChild(DOM.createElement("onlinemq"))
With .appendChild(DOM.createElement("header"))
With .appendChild(DOM.createElement("version"))
.Text = header.version
End With
With .appendChild(DOM.createElement("created_at"))
Set ATTR = DOM.createAttribute("type")
ATTR.Value = "datetime"
.Attributes.setNamedItem ATTR
.Text = header.created_at.XSDString
End With
With .appendChild(DOM.createElement("action"))
.Text = header.action
End With
End With
End With
XML = DOM.XML
End Property
-
Aug 26th, 2009, 08:50 AM
#4
Thread Starter
Addicted Member
Re: XML Data Types and VB6
I think what I am looking at is creating attributes for the type fields.
Does that help?
Dave
-
Aug 26th, 2009, 10:45 AM
#5
Re: XML Data Types and VB6
The sample code I listed above results in:
Code:
<onlinemq>
<header>
<version>1.0</version>
<created_at type="datetime">2009-08-26T11:43:29-04:00</created_at>
<action></action>
</header>
</onlinemq>
Are you sure this wasn't what you were after?
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
|