473,386 Members | 1,864 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,386 software developers and data experts.

HTML import

I've got this piece of code that imports an XML document ... it works
for both mozilla and IE.

function getXMl(url) {

if (!document.all) {
var xmlDoc = document.implementation.createDocument('','doc',nu ll);
var xmlHTTP = new XMLHttpRequest();
xmlHTTP.overrideMimeType("text/xml");
xmlHTTP.open("GET",url, false);
xmlHTTP.send(null);
xmlDoc=xmlHTTP.responseXML;
} else {
try {
xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
} catch (e) {
xmlDoc = new ActiveXObject("Msxml.DOMDocument");
}
xmlDoc.async="false";
xmlDoc.load(url);
}
return xmlDoc;
}

With mozilla i can use the same code to import an HTML file instead of
an XML file with no problems... but the object in IE expects a valid XML
file, so it does not work (xmlDoc.xml and xmlDoc.text gives me an
empty string output)...

Which is the object that will allow me to import an HTML file in IE?

thanks in advance.
alex.
Jul 23 '05 #1
2 3135


alex bazan wrote:
I've got this piece of code that imports an XML document ... it works
for both mozilla and IE.

function getXMl(url) {

if (!document.all) {
var xmlDoc = document.implementation.createDocument('','doc',nu ll);
var xmlHTTP = new XMLHttpRequest();
xmlHTTP.overrideMimeType("text/xml");
xmlHTTP.open("GET",url, false);
xmlHTTP.send(null);
xmlDoc=xmlHTTP.responseXML;
} else {
try {
xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
} catch (e) {
xmlDoc = new ActiveXObject("Msxml.DOMDocument");
}
xmlDoc.async="false";
xmlDoc.load(url);
}
return xmlDoc;
}

With mozilla i can use the same code to import an HTML file instead of
an XML file with no problems... but the object in IE expects a valid XML
file, so it does not work (xmlDoc.xml and xmlDoc.text gives me an empty
string output)...

Which is the object that will allow me to import an HTML file in IE?


You can use the download behavior with IE/Win if you want the text of an
HTML file, see
<http://www.faqts.com/knowledge_base/view.phtml/aid/1268/fid/126>

There is also
new ActiveXObject('Microsoft.XMLHTTP')
which has the same API as XMLHttpRequest thus if for Mozilla
responseText gives you what you need then you could use

var httpReqest;
if (typeof XMLHttpRequest != 'undefined') {
httpRequest = new XMLHttpRequest();
}
else if (typeof ActiveXObject != 'undefined') {
httpRequest = new ActiveXObject('Microsoft.XMLHTTP');
}
httpRequest.open('GET', url, true);
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState == 4) {
// use httpRequest.responseText here
alert(httpRequest.responseText);
}
};
httpRequest.send(null);
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
En/na Martin Honnen ha escrit:


There is also
new ActiveXObject('Microsoft.XMLHTTP')
which has the same API as XMLHttpRequest thus if for Mozilla
responseText gives you what you need then you could use


thanks this worked!!
alex.
Jul 23 '05 #3

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

Similar topics

6
by: Els | last post by:
***newbie question*** Hi, I am trying to make my server (Apache) parse .html files as .php. I found this line of code: ForceType application/x-httpd-php placed it in an .htaccess file and...
0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
8
by: Anders Eriksson | last post by:
Hello! I want to extract some info from a some specific HTML pages, Microsofts International Word list (e.g. http://msdn.microsoft.com/library/en-us/dnwue/html/swe_word_list.htm). I want to...
2
by: Thomas SMETS | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dear, I need to parse XHTML/HTML files in all ways : ~ _ Removing comments and javascripts is a first issue ~ _ Retrieving the list of fields...
10
by: George | last post by:
How can I parse an HTML file and collect only that the A tags. I have a start for the code but an unable to figure out how to finish the code. HTML_parse gets the data from the URL document. Thanks...
16
by: Philippe C. Martin | last post by:
Hi, I am trying to change the data in a form field from python. The following code does not crash but has no effect as if "form" is just a copy of the original html form. Must I recreate the...
13
by: DH | last post by:
Hi, I'm trying to strip the html and other useless junk from a html page.. Id like to create something like an automated text editor, where it takes the keywords from a txt file and removes them...
1
by: onceuponapriori | last post by:
Greetings gents. I'm a Railser working on a django app that needs to do some scraping to gather its data. I need to programatically access a site that requires a username and password. Once I...
6
by: liqfemail | last post by:
Below are my source code: import wx import wx.html class MyHtmlFrame(wx.Frame): def __init__(self, parent, title): wx.Frame.__init__(self, parent, -1, title, size=(600,400)) html =...
0
by: Subanesh | last post by:
Hi All, Am new to using HTMLUnit.I wrote a sample code(to emulate opening of website google.com and enter a value say "html" in the text field and click the Search button) .The code is as follows...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.