2

不幸的是,我们继承了一个旧的 Classic ASP 站点,并且正在为一个往返打孔站点编写新代码。读取 cXML 文件,我们不断地在第二行出错!DOCTYPE cXML SYSTEM "http://xml.../cXML.dtd。如果我们捕获dtd文件的位置并将其更改为本地文件,即file:///c:/....dtd它可以工作。有没有办法让它使用该http位置工作?我宁愿不在dtd本地存储所有文件版本。

我们的准则是:

    Dim olddtdvalue
    Dim newdtdvalue
    Dim xmlfilename
    olddtdvalue = "http://xml.cxml.org/schemas/cXML/"
    newdtdvalue = "file:///d:/Websites/FSIResponsive/cXML/"
    xmlfilename ="PORS_" & formatdatetime(now,vblongdate) & " " & replace(formatdatetime(now,vblongtime),":","_") &  ".xml"
    set fs=Server.CreateObject("Scripting.FileSystemObject") 
    set f=fs.CreateTextFile("d:\WebSites\FSIResponsive\cXML\InFiles\" & xmlfilename,true)
    f.write("remote host: " & request.ServerVariables("REMOTE_HOST") & vbcrlf & vbcrlf)
    totalBytes = Request.TotalBytes
    If totalBytes > 0 Then
        xml = Request.BinaryRead( totalBytes )
        for i = 1 to totalBytes
            xmlstr = xmlstr + String(1,AscB(MidB(xml, i, 1)))
        Next
        f.write(xmlstr)
        xml2 = xmlstr
        xml2 = Replace(xml2,olddtdvalue,newdtdvalue)
    End if
    Set xdoc = Server.CreateObject("Microsoft.XMLDOM")
'   Set xdoc = Server.CreateObject("MSXML2.DOMDocument.6.0")
    xdoc.ValidateOnParse = True
    xdoc.async = False
    xdoc.resolveExternals = True
'   response.write xml2 
    loadStatus = xdoc.loadXML(xml2)

如您所见,我们已经尝试使用MSXML2.DOMDocument.6.0,但这也不起作用。

谢谢,艾伦

更新:这是我终于开始工作的代码:

Dim xmlfilename
Dim URL
totalBytes = Request.TotalBytes
If totalBytes > 0 Then
    xml = Request.BinaryRead( totalBytes )
    for i = 1 to totalBytes
        xmlstr = xmlstr + String(1,AscB(MidB(xml, i, 1)))
    Next
    xml2 = xmlstr
End if
Set xdoc = Server.CreateObject("MSXML2.DOMDocument.6.0")
xdoc.setProperty "ServerHTTPRequest", True
xdoc.setProperty "ProhibitDTD",False
xdoc.resolveExternals = True
xdoc.ValidateOnParse = True
xdoc.async =  False
loadStatus = xdoc.LoadXML(xml2)

艾伦

4

0 回答 0