EDN Admin
Well-known member
Hi,
First time I try to send XML data over HTTP from vbscript to ASP, and...it doesnt work!
If I load an XML from my asp page, I can parse data normally.
If I send the same xml from my vbscript ASp gives me an error "XML document must have a top level element" at line 0
---------------------------------------<br/>
strxml = "c:brinote.xml"<br/>
<br/>
xmltext = "<ROOT>"<br/>
xmltext = xmltext & "<note>"<br/>
xmltext = xmltext & "<magazine>Test</magazine>"<br/>
xmltext = xmltext & "</note>"<br/>
xmltext = xmltext & "</ROOT>"<br/>
<br/>
Set objFSO = CreateObject("Scripting.FileSystemObject")<br/>
Set objTextFile = objFSO.OpenTextFile(strxml,2,True)<br/>
objTextFile.WriteLine(xmltext)<br/>
objTextFile.Close<br/>
<br/>
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")<br/>
xmlhttp.open "POST", "http://server/mdlsfix/receive.asp",False<br/>
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"<br/>
<br/>
Set xmldom = CreateObject("Microsoft.XMLDOM")<br/>
<br/>
xmlDom.load strxml<br/>
xmlhttp.send xmldom<br/>
MsgBox xmlhttp.responseText
---------------------------------------
When I run this reponsetext gives me the entire content of my XML (including tags)
My asp looks like this :<br/>
<%<br/>
set xmldom = Server.CreateObject("Microsoft.XMLDOM")<br/>
xmldom.Load(Request)<br/>
<br/>
If xmldom.parseError.errorCode <> 0 Then<br/>
Set myErr = xmldom.parseError<br/>
Response.Write myErr.reason<br/>
Response.Write xmlDom.parseError.line<br/>
else<br/>
strText = "You sent me: " & xmldom.xml<br/>
Response.Write xmldom.xml<br/>
end if<br/>
<br/>
%>
Result : XML document must have a top level element. 0
If I load the xml file directly instead of "request" I get "you sent me : Test"<br/>
Could you please advise me on this. Ive been browsing internet for days trying different exemples, without success.
Thanks in advance !!!
briac
View the full article
First time I try to send XML data over HTTP from vbscript to ASP, and...it doesnt work!
If I load an XML from my asp page, I can parse data normally.
If I send the same xml from my vbscript ASp gives me an error "XML document must have a top level element" at line 0
---------------------------------------<br/>
strxml = "c:brinote.xml"<br/>
<br/>
xmltext = "<ROOT>"<br/>
xmltext = xmltext & "<note>"<br/>
xmltext = xmltext & "<magazine>Test</magazine>"<br/>
xmltext = xmltext & "</note>"<br/>
xmltext = xmltext & "</ROOT>"<br/>
<br/>
Set objFSO = CreateObject("Scripting.FileSystemObject")<br/>
Set objTextFile = objFSO.OpenTextFile(strxml,2,True)<br/>
objTextFile.WriteLine(xmltext)<br/>
objTextFile.Close<br/>
<br/>
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")<br/>
xmlhttp.open "POST", "http://server/mdlsfix/receive.asp",False<br/>
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"<br/>
<br/>
Set xmldom = CreateObject("Microsoft.XMLDOM")<br/>
<br/>
xmlDom.load strxml<br/>
xmlhttp.send xmldom<br/>
MsgBox xmlhttp.responseText
---------------------------------------
When I run this reponsetext gives me the entire content of my XML (including tags)
My asp looks like this :<br/>
<%<br/>
set xmldom = Server.CreateObject("Microsoft.XMLDOM")<br/>
xmldom.Load(Request)<br/>
<br/>
If xmldom.parseError.errorCode <> 0 Then<br/>
Set myErr = xmldom.parseError<br/>
Response.Write myErr.reason<br/>
Response.Write xmlDom.parseError.line<br/>
else<br/>
strText = "You sent me: " & xmldom.xml<br/>
Response.Write xmldom.xml<br/>
end if<br/>
<br/>
%>
Result : XML document must have a top level element. 0
If I load the xml file directly instead of "request" I get "you sent me : Test"<br/>
Could you please advise me on this. Ive been browsing internet for days trying different exemples, without success.
Thanks in advance !!!
briac
View the full article