Ignoring XML DTD with Excel VBA

RM2106

New Member
Joined
Dec 22, 2013
Messages
5
Hi,

I am trying to write a macro to load an XML file to memory and then walk through its various nodes and perform some actions. However, the XML documents that my macro is supposed to read contains a reference to an external DTD and each time when I run my code, I am getting the following error:

Code:
D:\test.xml      Invalid at the top level of the document.              
Src: [QUOTE][/QUOTE]

For some strange reason, Mr.Excels editor is removing the Src: content
The "task.dtd" file is available at another location ("C:\DITA\dtd\technicalContent\dtd").

Is there any way for me to ignore the DTD validation altogether? Or, can anyone suggest a way so that my code goes to the correct location to load the task.dtd file?

Here is the code I have written so far:

Code:
Sub try1_not_in_use()Dim xmlDoc: Set xmlDoc = CreateObject("Microsoft.XMLDOM")




  Dim xmlurl
  For Each xmlurl In Array("D:\test.xml")
    xmlDoc.async = False
    xmlDoc.SetProperty "ProhibitDTD", True
    If xmlDoc.Load(xmlurl) Then
       With xmlDoc.DocumentElement.FirstChild
          Debug.Print xmlurl _
                       , .tagName _
                       , .text
       End With
    Else
       Debug.Print xmlurl, xmlDoc.parseError.reason, "Src:", xmlDoc.parseError.srcText
    End If
  Next
End Sub

Thanks,
Raman
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,214,869
Messages
6,122,015
Members
449,060
Latest member
LinusJE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top