Skip to content Skip to sidebar Skip to footer

Classic Asp Htmlfile Object Remove Child

have to extract some info from an HTML File and strip out a div and I need to use classic asp. I'm using HTMLFile object and it works everything except when I try to remove the div

Solution 1:

I think that the Docs for HTMLFILE start here.

According to the docs for removeChild, the incantation needed to remove node X is:

X.parentNode.removeChild X

If you change the delete demo code from here

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

to

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

you should get

...

-----------------
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"
-----------------
...

Post a Comment for "Classic Asp Htmlfile Object Remove Child"