![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: XML Posted documents fail XML Posted documents failTo: NULL Date: 11/1/2006 11:19:00 AM
I have had an application running for a few years that has been working
with no problems. Recently I upgraded my browser to IE7 and started
experiencing problems.
I had a page with a huge textarea in which I would copy in an XML
document. I then would push a button and the text would be loaded as
an XMLDOM object and posted to an XSQL page on the same server. The
returned XML response would be parsed and the results shown.
My guess would be that either
a) There are some security settings that have changed in the browser.
(If so, what are they and how can I either rewrite the code to not fail
on them?)
b) Some of the functionality of either the XMLDom or the
Microsoft.XMLHTTP has changed. (Again what can be done to correct?)
The core of the code is something like this:
<HTML>
<HEAD>
<SCRIPT src="../PostXMLDocument.js"></SCRIPT>
<SCRIPT>
function parseXMLinTextAreaAndPostIt(){
StatusArea.innerText = "";
// Create a new XML Parser Object
var xmldoc = new ActiveXObject ("Microsoft.XMLDOM");
// Do the parsing synchronously
xmldoc.async = false;
// Parse the text in the TEXTAREA as XML
xmldoc.loadXML(xmldocText.value);
// check load for success
err = xmldoc.parseError;
if (err != 0) {
StatusArea.innerText = "Your XML document is not
well-formed.\n" + err.srcText +
"\n" + "Line " + err.line + ", Pos " + err.linepos + "\n" +
err.reason;
return;
}
// Post the parsed XML document to the xsql Page
var response = PostXMLDocument(xmldoc, "send_order.xsql");
// Display the XML text of the response in the "StatusArea" DIV
var result = response.selectSingleNode("//OK");
if (result != null) {
StatusArea.innerText = response.documentElement.xml;
alert("Successfully posted: \n" + result.text);
}
else {
result = response.selectSingleNode("//ERROR");
if (result != null) {
alert(result.text);
}
else {
alert("No XML response received.");
}
}
}
</SCRIPT>
</HEAD>
<BODY>
<b>Paste or type in an XML Document:<b><br>
<TEXTAREA rows="18" style="width:100%" cols="80" name="xmldocText">
</TEXTAREA>
<INPUT TYPE="button" Value="Post XML Document"
onclick="parseXMLinTextAreaAndPostIt()">
<br><br>Response:<hr>
<DIV id="StatusArea" style="font-family:monospace"></DIV>
</BODY>
</HTML>
The PostXMLDocument.js is very simple as well and looks like this:
// Uses HTTP POST to send XML Document "xmldoc" to URL "toURL"
function PostXMLDocument (xmldoc, toURL)
{
var oReq = new ActiveXObject("Microsoft.XMLHTTP");
oReq.open("POST", toURL, false);
oReq.setRequestHeader('Content-type','text/xml');
oReq.send(xmldoc);
return oReq.responseXML;
}
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
