Article ID: 254643
Article Last Modified on 8/14/2007
APPLIES TO
- Microsoft Internet Explorer 5.0
- Microsoft Internet Explorer 5.01
- Microsoft XML Parser 2.5
- Microsoft XML Parser 2.6
- Microsoft XML Parser 3.0
- Microsoft XML Core Services 4.0
This article was previously published under Q254643
SYMPTOMS
When you use the loadXML method to load an XML string that references an external document type definition (DTD) or schema on the server side in an Active Server Pages (ASP) page, the following error message may appear:
CAUSE
The Microsoft XML parser (MSXML) cannot determine the physical location of the file from a relative path.
RESOLUTION
To resolve this problem, use an absolute path instead of a relative path. You can use either a full Universal Naming Convention (UNC) path or a file path. You can use the MapPath method of the server object to map a specified relative or virtual path to the corresponding physical folder on the server.
MORE INFORMATION
Internet Explorer 5.01 fixes another problem with similar symptoms in which DTDs and schemas are not resolved when you use the loadXML method. See the "References" section for additional information on that problem.
After you install Internet Explorer 5.01, you can use loadXML with DTDs or schemas in a client-side script without problem. However, you will still experience the problem when you use a relative path on the server side.
The loadXML method merely takes a string of XML into memory. When this string has a reference to an external DTD or schema, MSXML attempts to load the file. If the path is a relative path, MSXML has no way to locate the file and fails to process the DTD or schema.
If a newer version of MSXML has been installed in side-by-side mode, you must explicitly use the Globally Unique Identifiers (GUIDs) or ProgIDs for that version to run the sample code. For example, MSXML version 4.0 can only be installed in side-by-side mode. For additional information about the code changes that are required to run the sample code with the MSXML 4.0 parser, click the following article number to view the article in the Microsoft Knowledge Base:
305019 INFO: MSXML 4.0 Specific GUIDs and ProgIds
Steps to Reproduce Behavior
Create a file named Repro.dtd and paste the following code:
<!ELEMENT Root (Data)> <!ELEMENT Data (#PCDATA)>
Create an ASP page named Repro.asp and paste the following code:
<%@ Language=VBScript %> <HTML> <HEAD></HEAD> <BODY> <% Dim oXML Dim strXML Dim dtdpath Set oXML = Server.CreateObject("MSXML.DOMDocument") To use version 4 of the MSXML parser, for example, change the CreateObject statement to: Set oXML = Server.CreateObject("MSXML2.DOMDocument.4.0") oXML.async = false oXML.resolveExternals = True oXML.validateOnParse = True 'This WILL NOT work. strXML = "<?xml version='1.0'?> " & _ "<!DOCTYPE Root SYSTEM 'REPRO.DTD'>" & _ "<Root><Data> some data</Data></Root>" 'This WILL work. 'dtdpath = Server.MapPath("REPRO.DTD") 'strXML = "<?xml version='1.0'?> " & _ ' "<!DOCTYPE Root SYSTEM '" & dtdpath & "'>" & _ ' "<Root><Data>Got the data</Data></Root>" If not oXML.loadXML(strXML) Then Response.write oXML.parseError.reason Else Response.Write oXML.XML End If %> </BODY> </HTML>
- Deploy both files to your Web server.
- In Internet Explorer, browse to Repro.asp. Either the data or an error is displayed.
REFERENCES
For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:
Platform SDK, Server.MapPath
For additional information237906, click the article numberPRB: Loading Remote XML or Sending XML HTTP Requests from Server Is Not Supported below to view the articlePRB: Loading Remote XML or Sending XML HTTP Requests from Server Is Not Supported in the Microsoft Knowledge Base:
%3 %4
%1 %2
Additional query words: script DOCTYPE
Keywords: kbprb kbsbnworkshop KB254643