Hi All,
I need to use VBA (in Access) to manipulate XML nodes. I'm having a crazy difficult time. I found some code online to help me out and this is what I pulled together. I keep getting an error saying that the 'XML document must have a top level element'. The error code is -1072896680 (c00ce558). I tried refencing Microsoft XML 3.0, 4.0 and 6.0 but always the same error.
Public Sub ModifyXML()
Dim myxml As MSXML2.DOMDocument
Dim myxmlstr As String
Set myxml = New MSXML2.DOMDocument
myxml.Load ("C:\Temp\xmldoc.xml")
If Not myxml.loadXML(myxmlstr) Then
Err.Raise myxml.parseError.errorCode, , myxml.parseError.reason
End If
'and now i'm supposed to be able to manipulate the code, but the error pops up instead
End Sub
The XML fine, I pasted it below and I tried a whole bunch of other variations of it too.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
I found someone post a message about a forum that is supposed to be helpful for such things. But seems like this is for Visual Basic 6... so I should be able to use it with VBA right (I'm using MS Office 2003 at work... I know... but I have no choice)? I can't post the link 'cause I'm not at 10 posts yet... I get it... its for the robot spammers. But you can try searching ChilKatXML.
I need to use VBA (in Access) to manipulate XML nodes. I'm having a crazy difficult time. I found some code online to help me out and this is what I pulled together. I keep getting an error saying that the 'XML document must have a top level element'. The error code is -1072896680 (c00ce558). I tried refencing Microsoft XML 3.0, 4.0 and 6.0 but always the same error.
Public Sub ModifyXML()
Dim myxml As MSXML2.DOMDocument
Dim myxmlstr As String
Set myxml = New MSXML2.DOMDocument
myxml.Load ("C:\Temp\xmldoc.xml")
If Not myxml.loadXML(myxmlstr) Then
Err.Raise myxml.parseError.errorCode, , myxml.parseError.reason
End If
'and now i'm supposed to be able to manipulate the code, but the error pops up instead
End Sub
The XML fine, I pasted it below and I tried a whole bunch of other variations of it too.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
I found someone post a message about a forum that is supposed to be helpful for such things. But seems like this is for Visual Basic 6... so I should be able to use it with VBA right (I'm using MS Office 2003 at work... I know... but I have no choice)? I can't post the link 'cause I'm not at 10 posts yet... I get it... its for the robot spammers. But you can try searching ChilKatXML.