本文介绍了传统的ASP HTMLFILE对象中删除子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要提取从HTML文件中的一些信息,并去掉一个div,我需要使用传统的ASP。

have to extract some info from an HTML File and strip out a div and I need to use classic asp.

我使用HTMLFILE对象和它的作品除了当我尝试删除DIV一切

I'm using HTMLFile object and it works everything except when I try to remove the div

这里例程的相关部分:

.......

Set HTML = CreateObject("HTMLFile")
Set Frame = CreateObject("HTMLFile")  

.........  

tmp=t.ReadAll
HTML.Write tmp
t.close

Set SPN=HTML.getElementsByTagName("div")
for each sp in SPN
    if sp.getAttribute("id")="frame" then
        Frame.write sp.InnerHTML
        exit for
    end if
next        

Set Divs=Frame.getElementsByTagName("div")
for each div in Divs
    if div.getAttribute("id")="link_1" then
        Frame.removeChild(div)
    end if
next

返回

HTMLFILE错误'80070057'结果
  无效的参数结果
  57号线

在哪里的命令是 Frame.Removechild(DIV)

可以提出解决方案或一个链接,可以找到有关HTMLFILE对象文档..因为我用Google搜索了很多,但显然与错误的关键词

can suggest solution or a link where can find documentation about HTMLFile Object.. since I googled a lot but apparently with wrong keywords

感谢

推荐答案

我觉得,该文档为HTMLFILE开始的。

I think that the Docs for HTMLFILE start here.

根据文档的 更改删除演示code

If you change the delete demo code from here

oDOM.childNodes(0).childNodes(1).removeChild DOM.childNodes(0).childNodes(1).childNodes(0)

  Set p = oDOM.getElementsByTagName("P")(0)
  p.parentNode.removeChild p
  WScript.Echo "After deleting first P"
  dumpDoc oDOM

你应该得到的。

...

-----------------
After changing second P's .innerTEXT to "pipapo"
 oDOM.documentElement: HTML
 oDOM.childNodes.length 1
   1 HTML "<HEAD></HEAD><BODY><P>G</P><P>pipapo</P></BODY>"
    1 HEAD ""
     1 TITLE ""
    1 BODY "<P>G</P><P>pipapo</P>"
     1 P "G"
      3 #text "G"
     1 P "pipapo"
      3 #text "pipapo"
-----------------
After deleting first P
 oDOM.documentElement: HTML
 oDOM.childNodes.length 1
   1 HTML "<HEAD></HEAD><BODY><P>pipapo</P></BODY>"
    1 HEAD ""
     1 TITLE ""
    1 BODY "<P>pipapo</P>"
     1 P "pipapo"
      3 #text "pipapo"
-----------------
...

这篇关于传统的ASP HTMLFILE对象中删除子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!