473,385 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

responseXML in Internet Explorer

I'm having trouble figuring out what's going on with IE6's
Msxml2.XMLHTTP object. I have two feed addresses in this stripped down
version of my code below. Both work fine in Firefox (using the
XMLHttpRequest object), but only the thinkgeek one works in IE. In the
processFeed function, it shows the problem - the first alert shows 0
for the wikihow feed in IE, though it can still display the
responseText. Any insight?
//var feedAddr = "http://www.thinkgeek.com/thinkgeek.rss"; <<< works
fine in both
var feedAddr = "http://www.wikihow.com/feed.rss"; <<< only works in
FF

var url = "http://.../getXML.asp?url=" + feedAddr; <<< returns XML w/
content type text/xml
loadXMLDoc(url);

function loadXMLDoc(url)
{
var req;
if(window.XMLHttpRequest)
{
try { req = new XMLHttpRequest(); }
catch(e) { req = false; }
}
else if(window.ActiveXObject)
{
try { req = new ActiveXObject("Msxml2.XMLHTTP"); }
catch(e)
{
try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
catch(e) { req = false; }
}
}
if(req)
{
req.onreadystatechange = function(){ processReqChange(req); };
req.open("GET", url, true);
req.send("");
}
else { XMLObjError(); }
}
function processReqChange(req)
{
if (req.readyState == 4)
{
if (req.status == 200) { processFeed(req); }
else { XMLReqError(); }
}
}
function processFeed(req)
{
var xmlDoc = req.responseXML;
alert(xmlDoc.childNodes.length); <<< shows 0 in IE for the wikihow
feed
alert(req.responseText);

//... do stuff
}

Aug 18 '06 #1
6 4234


wi**********@hotmail.com wrote:
I'm having trouble figuring out what's going on with IE6's
Msxml2.XMLHTTP object. I have two feed addresses in this stripped down
version of my code below. Both work fine in Firefox (using the
XMLHttpRequest object), but only the thinkgeek one works in IE. In the
processFeed function, it shows the problem - the first alert shows 0
for the wikihow feed in IE, though it can still display the
responseText. Any insight?
//var feedAddr = "http://www.thinkgeek.com/thinkgeek.rss"; <<< works
fine in both
var feedAddr = "http://www.wikihow.com/feed.rss"; <<< only works in
FF

var url = "http://.../getXML.asp?url=" + feedAddr; <<< returns XML w/
content type text/xml
loadXMLDoc(url);
So in terms of the client side code you do not make a request to the URL
http://www.wikihow.com/feed.rss but rather to some different server that
then fetches the URL? Then look into that getXML.asp code and whether it
returns anything different.
Things to check on the client:

req.getAllResponseHeaders()
req.responseXML.parseError.errorCode
req.responseXML.parseError.reason

Show us the response headers you get. Or post the URL of that getXML.asp
script so that we can check what it returns.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 18 '06 #2

Martin Honnen wrote:
So in terms of the client side code you do not make a request to the URL
http://www.wikihow.com/feed.rss but rather to some different server that
then fetches the URL?
Yes, as far as I know, from the client side you can only make a request
to the same server as the page (that's the only way I could get it to
work anyway).
The asp script is only on my local server at the moment, so here's the
code:
function loadXML(byval xmlAddress)
dim xmlDoc

'Load the XML
set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.async = false
xmlDoc.setProperty "ServerHTTPRequest", true
on error resume next
xmlDoc.load(xmlAddress)
if err 0 then
set loadXML = null
exit function
end if
set loadXML = xmlDoc
end function
dim x
dim address
dim content
address = request.QueryString("url")
if address <"" then
set x = loadXML(address)
if isnull(x) or x.xml = "" then
response.Status = "404 Not Found"
response.End()
else
content = x.xml
end if
end if
response.ContentType = "text/xml"
response.Write(content)

Then look into that getXML.asp code and whether it
returns anything different.
The getXML.asp returns the same thing as going to the feed url
directly.
Things to check on the client:

req.getAllResponseHeaders()
req.responseXML.parseError.errorCode
req.responseXML.parseError.reason

Show us the response headers you get. Or post the URL of that getXML.asp
script so that we can check what it returns.
Here's what it returns in IE for the wikihow feed:
X-Powered-By: ASP.NET Content-Length: 6996 Content-Type: text/xml

-1072896760

An invalid character was found in text content.
I have no idea what this means...

Thanks for your help Martin.

Aug 18 '06 #3


wi**********@hotmail.com wrote:

set x = loadXML(address)
if isnull(x) or x.xml = "" then
response.Status = "404 Not Found"
response.End()
else
content = x.xml
end if
end if
response.ContentType = "text/xml"
response.Write(content)
Don't do that response.Write(content), instead simply do
x.save Response
if you want to send the loaded XML to the browser.
-1072896760

An invalid character was found in text content.
That means that MSXML in IE can't parse the XML your ASP returns as it
is not able to decode the bytes to characters, caused by changes in the
character encoding that probably occur due to your ASP page writing out
text in a certain code page that is different from the encoding the XML
doccument declares in its XML declaration. I hope my suggested change to
your ASP script fixes that problem.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 18 '06 #4

Martin Honnen wrote:
Don't do that response.Write(content), instead simply do
x.save Response
if you want to send the loaded XML to the browser.
-1072896760

An invalid character was found in text content.

That means that MSXML in IE can't parse the XML your ASP returns as it
is not able to decode the bytes to characters, caused by changes in the
character encoding that probably occur due to your ASP page writing out
text in a certain code page that is different from the encoding the XML
doccument declares in its XML declaration. I hope my suggested change to
your ASP script fixes that problem.
Thanks for the explanation. That change didn't have any effect,
however.

Aug 18 '06 #5


wi**********@hotmail.com wrote:

That change didn't have any effect,
however.
It is an ASP problem not a JavaScript problem. One way with MSXML and
ASP to grab another URL and send it to the client unchanged could be
alike (very rough outline, no error checking)

Set HttpRequest = CreateObject("Msxml2.ServerXMLHTTP.3.0")
HttpRequest.open "GET", Request.QueryString("url"), False
HttpRequest.send

If HttpRequest.status = 200 Then
Response.ContentType = HttpRequest.getResponseHeader("Content-Type")
Response.BinaryWrite HttpRequest.responseBody
End

I hope those lines help, if not consider asking in a Microsoft group on
ASP or XML (e.g. microsoft.public.xml).

Or use J(ava)Script in ASP :), then we could deal with it here without
getting off topic.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 18 '06 #6
Your first suggestion DID work! I just had to close IE and open it
again 'cause it wasn't refreshing - sheesh!

Thanks!

Aug 18 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Raymond H. | last post by:
Hello, I create a vb4 project which can also naviger on Internet via the WebBrowser control which I put on my form. My question is: if this program is installed on a station having already...
3
by: Alexander Mikhailian | last post by:
I have an http = new XMLHttpRequest(); that provides me with an http.responseXML. Somewhere deep in the http.responseXML there is a fragment called e.g. mydom that I want to copy with all its...
2
by: CathieC | last post by:
I have a websote developed using visual studio 2005 beta , .net version 2 i deploy my application to a server and it is run from client computers. One of the users gets the error "Internet...
3
by: VK | last post by:
Internet Explorer 7 beta 2 preview CNET Editor review: <http://reviews.cnet.com/Internet_Explorer_7_for_XP_SP2_Beta_2/4505-3514_7-31454661-2.html?tag=nl.e415> Summary (my personal review...
11
by: Wendy | last post by:
Hello, I have a program that does the following: When a user clicks on a row in a VB.NET datagrid, it will open a web page in Internet Explorer (that corresponds to that item in the selected row...
14
by: webEater | last post by:
I downloaded IE7 and tried out the native XMLHttpRequest support. I think there is an object in IE7 called "XMLHttpRequest" but I ask me why it is called "XML"HttpRequest. I made a request to an...
3
by: laredotornado | last post by:
Hi, This problem only affects PC IE. On a secured page (a page visited via https), there is a link that reads -- "Download HTML File". The link connects to this page <?php...
9
by: Etayki | last post by:
Hi! I am new to VB.net and I am using the Visual Basic 2005 Express Edition I have two questions: 1. I am trying to write an application that will automate Internet Explorer and store data...
1
by: -Lost | last post by:
This is more of a post to inform, unless of course I am missing something fundamental, in which case I would appreciate anyone explaining it. Based on Mr. Michaux's camelizeStyle function I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.