I am trying to read a html page (file) including its tags line by line, and then inserting it to database using classic ASP. My problem is that I can not read html tags Like
我尝试逐行读取包含其标记的html页面(文件),然后使用经典的ASP将其插入数据库。我的问题是我不能读取html标签。
<p>Test</p>
or
或
<td width="20%">Hello</td>
instead I read "Test" or "Hello". I also know that I have to convert " to ', when am I supposed to replace it? Here is my read code:
相反,我读“Test”或“Hello”。我也知道我必须转换成,我什么时候应该替换它?以下是我的阅读代码:
Dim url,strArr,xmlhttp,lineno
url = "http://localhost/0/questions/q.html"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET", url, false
xmlhttp.send ""
strArr = split(xmlhttp.responseText,vbcrlf)
set xmlhttp = nothing
for lineno=0 to ubound(strArr)
' Here I do replacement, parsing and then insertion to database
next
2 个解决方案
#1
1
Try this:
试试这个:
Dim url,strArr,xmlhttp,lineno
url = "http://localhost/0/questions/q.html"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET", url, false
xmlhttp.send ""
strArr = split(xmlhttp.responseText,vbcrlf)
set xmlhttp = nothing
for lineno=0 to ubound(strArr)
response.write(Replace(strArr(lineno),"<","<'"))
next
If you placed just response.write(strArr(lineno)) in your page you will see only what is inside html tag not the tag itself. But if you do insert of that strArr(lineno) into database all will be there.For as long as you replace all apostrophes.
如果您在页面中放置response.write(strArr(lineno)),您将看到的只是html标记内部的内容,而不是标记本身。但是如果你将strArr(lineno)插入到数据库中,所有的都将在那里。只要你替换掉所有的撇号。
#2
1
Try to use responseHTML instead of responseText:
尝试使用responseHTML而不是responseText:
strArr = split(xmlhttp.responseHTML,vbcrlf)
#1
1
Try this:
试试这个:
Dim url,strArr,xmlhttp,lineno
url = "http://localhost/0/questions/q.html"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET", url, false
xmlhttp.send ""
strArr = split(xmlhttp.responseText,vbcrlf)
set xmlhttp = nothing
for lineno=0 to ubound(strArr)
response.write(Replace(strArr(lineno),"<","<'"))
next
If you placed just response.write(strArr(lineno)) in your page you will see only what is inside html tag not the tag itself. But if you do insert of that strArr(lineno) into database all will be there.For as long as you replace all apostrophes.
如果您在页面中放置response.write(strArr(lineno)),您将看到的只是html标记内部的内容,而不是标记本身。但是如果你将strArr(lineno)插入到数据库中,所有的都将在那里。只要你替换掉所有的撇号。
#2
1
Try to use responseHTML instead of responseText:
尝试使用responseHTML而不是responseText:
strArr = split(xmlhttp.responseHTML,vbcrlf)