(1) the XML you posted is bad
(2) your .xml file is probably bad too
(3) according to
http://social.msdn.micros...47de-9840-c66af68d6c85 http://msdn.microsoft.com...y/ms757837(VS.85).aspx you shouldn't use the ancient XMLDOM but the best/newest
version of DomDocument
(4) You should check the .parseError, if the .load fails
All this in code
Dim aXmlFSpecs : aXmlFSpecs = Array( _
"M:\lib\kurs0705\testdata\xml\nattu\nattu-org-bad.xml" _
, "M:\lib\kurs0705\testdata\xml\nattu\nattu-simple.xml" _
, "M:\lib\kurs0705\testdata\xml\nattu\nattu-wdtd.xml" _
)
Dim aClsIds : aClsIds = Array( _
"Microsoft.XMLDOM" _
, "Msxml2.DOMDocument" _
)
Dim sFSpec, sClsId
For Each sFSpec In aXmlFSpecs
For Each sClsId In aClsIds
WScript.Echo "using", sClsId, "to read", sFSpec
Dim oXDoc : Set oXDoc = CreateObject( sClsId )
oXDoc.async = False
Dim bOk : bOk = oXDoc.load( sFSpec )
If bOk Then
WScript.Echo "looks ok:", oXDoc.documentElement.tagName
Else
WScript.Echo "Bingo:", oXDoc.parseError.reason
End If
Next
Next
output:
loadXML00 - load an .xml doc (nattu)
-------------------------------------------------------------------------------
using Microsoft.XMLDOM to read M:\lib\kurs0705\testdata\xml\nattu\nattu-org-bad.xml
Bingo: The element 'PSRequest' is used but not declared in the DTD/Schema.
using Msxml2.DOMDocument to read M:\lib\kurs0705\testdata\xml\nattu\nattu-org-bad.xml
Bingo: The element 'PSRequest' is used but not declared in the DTD/Schema.
using Microsoft.XMLDOM to read M:\lib\kurs0705\testdata\xml\nattu\nattu-simple.xml
looks ok: PSRequest
using Msxml2.DOMDocument to read M:\lib\kurs0705\testdata\xml\nattu\nattu-simple.xml
looks ok: PSRequest
using Microsoft.XMLDOM to read M:\lib\kurs0705\testdata\xml\nattu\nattu-wdtd.xml
looks ok: note
using Msxml2.DOMDocument to read M:\lib\kurs0705\testdata\xml\nattu\nattu-wdtd.xml
looks ok: note
===============================================================================
xplxml.vbs: Erfolgreich beendet. (0) [ 0.12891 secs ]
I got the nattu-wdtd.xml from
www.w3schools.com:
<?xml version="1.0" encoding="iso-8859-1" ?>
<!-- http://www.w3schools.com/DTD/dtd_intro.asp -->
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend</body>
</note>