Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: why do I get question marks instead of bullets ??? >Thread Next - Re: why do I get question marks instead of bullets ??? Re: why do I get question marks instead of bullets ???To: NULL Date: 6/15/2004 8:58:00 AM Thanks but ...
Is it really necessary to write a file and then read it back, just to
obtain the proper characters ?
Here's a working example , but note how it writes and then reads file
"tempSearchData.html" .
I've LOVE to avoid the write-file-then-read-it-back step . Any ideas
????
Here's my code so far:
<!--
Adodb trial
Author: EricOsman@r... 15-Jun-2004
-->
<html>
<head>
<title>Try adodb </title>
<script>
//+-------------------------------------------------------------
//| Here when page loads. (on refresh too ? On "back" button
//| that arrives at this page again ?)
//+-------------------------------------------------------------
function onLoad() {
}
//+-------------------------------------------------------------
//| Put your test code here then click the tryit button to give
//| it a world.
//+-------------------------------------------------------------
function tryit() {
document.getElementById("resultsDiv").innerHTML = "Processing ...";
var req = new ActiveXObject('Msxml2.XMLHTTP');
var url = "http://www.aaamidatlantic.com/savings/default_aloha.asp";
req.open('GET', url, false);
//req.setRequestHeader("Content-Type", 'text/xml;
charset="ISO-8859-1"');
//req.setRequestHeader("Accept-Charset", "iso-8859-1");
req.send();
var stream = new ActiveXObject("ADODB.Stream");
// checkStatus(http, 200);
stream.open();
stream.Type = 1;
try {
if (req.responseText.length > 0) {
stream.Write(req.responseBody);
}
else {
alert ("responseText is empty");
return;
}
}
catch (e) {
var report = "";
for (var i in e) {
report += i + ":" + e[i] + "\n";
}
alert ("Error:\n------\n" + report);
return;
}
var fileName = "tempSearchData.html";
stream.SaveToFile(fileName, 2);
stream.close();
// This incantation from
http://www.codeproject.com/asp/gethtmlsource.asp?df=100&forumid=4081&exp=0&select=696350
//set strm2=createobject("adodb.stream")
//With strm2
//.type = 2
//.charset="euc-kr" 'Use any proper charset
//.open
//.loadfromFile
var stream = new ActiveXObject("ADODB.Stream");
stream.Type = 2;
stream.Charset = "iso-8859-1";
stream.open();
stream.LoadFromFile(fileName);
//var t = req.ResponseText;
var t = stream.ReadText();
t = t.substring(t.indexOf("Member Benefits include"), t.length);
var endStr = "discount off first";
t = t.substring(0, t.indexOf(endStr) + endStr.length);
document.getElementById("resultsDiv").innerHTML = "done";
document.getElementById("resultsDiv").innerHTML =
"Can you see the bullets in the this text ?<br>"
+ t;
}
</script>
<body onload="onLoad();">
<button onClick="tryit();">Let's Try It</button>
<div id=resultsDiv>
</div>
</body>
</html>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
