Re: A HTML Parser Bug?
[email protected] (Michael Song) Mon, 16 Sep 2013 10:32:38 -0700
| Newsgroups | perl.libwww |
|---|---|
| Message-ID | <CADG0jyDSfAu8xpefSUFCKy5YMvfud-7+7WFR5iev76_obLepJg@mail.gmail.com> |
--047d7b15a1d12fbb2804e683975f Content-Type: text/plain; charset=ISO-8859-1 HI Gisle, I figured out the root cause of the problem this line <META content=3.9 itemprop="rating"> in the html body will throw a START Event to perl but this line is without END event and consequently causes TreeBuilder to start a new branch. my quick fix is to ignore the START event if tag is 'meta'. The code hparser.c just works fine as i stepped through the code. A future proof fix will require adding some logic on TreeBuilder to close any open closures if its parent is closing. Thanks On Sun, Sep 8, 2013 at 7:50 AM, Michael Song <[email protected]>wrote: > Hell All, > I've attached my html source code to demonstrate a incompatible parsing > behavior between Parser and Firefox firebug > If you open the below attached file with Firefox firebug, you will see > <div class="gd-grid-6 product-pricing"> is inside <div > class="listing-page-bucket"> enclosure > but when you parse it, the above relationship does not in the tree, > Is there anyway I can get around this problem? > > > Thanks > > > > > > --047d7b15a1d12fbb2804e683975f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">HI Gisle,<div>I figured out the root cause of the problem<= /div><div><span style=3D"font-family:'Courier New';font-size:10pt;c= olor:rgb(128,0,0)">this line</span></div><div><span style=3D"font-family:&#= 39;Courier New';font-size:10pt;color:rgb(128,0,0)"><</span><span sty= le=3D"font-family:'Courier New';font-size:10pt;color:rgb(128,0,128)= ">META</span><span style=3D"color:rgb(0,0,0);font-family:'Courier New&#= 39;;font-size:10pt"> </span><span style=3D"color:rgb(0,0,0);font-family:= 9;Courier New';font-size:10pt">content</span><span style=3D"font-family= :'Courier New';font-size:10pt;color:rgb(128,0,0)">=3D</span><span s= tyle=3D"font-family:'Courier New';font-size:10pt;color:rgb(0,128,12= 8)">3.9</span><span style=3D"color:rgb(0,0,0);font-family:'Courier New&= #39;;font-size:10pt"> itemprop</span><span style=3D"font-family:'Courie= r New';font-size:10pt;color:rgb(128,0,0)">=3D</span><span style=3D"font= -family:'Courier New';font-size:10pt;color:rgb(0,128,128)">"ra= ting"</span><span style=3D"font-family:'Courier New';font-size= :10pt;color:rgb(128,0,0)">></span></div> <div><span style=3D"font-family:'Courier New';font-size:10pt;color:= rgb(128,0,0)">in the html body will throw a START Event to perl</span></div= ><div><span style=3D"font-family:'Courier New';font-size:10pt;color= :rgb(128,0,0)"><br> </span></div><div><font color=3D"#800000" face=3D"Courier New">but this lin= e is without END event and=A0</font><font color=3D"#800000" face=3D"Courier= New">consequently causes TreeBuilder to start a new branch.</font></div><d= iv><font color=3D"#800000" face=3D"Courier New">my quick fix is to ignore t= he START event if tag is 'meta'. The code hparser.c just works fine= as i stepped through the code.</font></div> <div><font color=3D"#800000" face=3D"Courier New"><br></font></div><div><fo= nt color=3D"#800000" face=3D"Courier New">A future proof fix will require a= dding some logic on=A0</font><span style=3D"color:rgb(128,0,0);font-family:= 'Courier New'">TreeBuilder to close any open closures if its parent= is closing.</span></div> <div><font color=3D"#800000" face=3D"Courier New"><br></font></div><div><fo= nt color=3D"#800000" face=3D"Courier New">Thanks</font></div><div><br></div= ><div><font color=3D"#800000" face=3D"Courier New">=A0</font></div><div><sp= an style=3D"font-family:'Courier New';font-size:10pt;color:rgb(128,= 0,0)"><br> </span></div><div><span style=3D"font-family:'Courier New';font-siz= e:10pt;color:rgb(128,0,0)"><br></span></div><div><span style=3D"font-family= :'Courier New';font-size:10pt;color:rgb(128,0,0)"><br></span></div> <div><span style=3D"font-family:'Courier New';font-size:10pt;color:= rgb(128,0,0)"><br></span></div><div><span style=3D"font-family:'Courier= New';font-size:10pt;color:rgb(128,0,0)"><br></span></div><div><span st= yle=3D"font-family:'Courier New';font-size:10pt;color:rgb(128,0,0)"= ><br> </span></div></div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_q= uote">On Sun, Sep 8, 2013 at 7:50 AM, Michael Song <span dir=3D"ltr"><<a= href=3D"mailto:[email protected]" target=3D"_blank">michael.l.song@= gmail.com</a>></span> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><div><div><div><div><d= iv>Hell All,<br></div>I've attached my html source code to demonstrate = a incompatible parsing behavior between Parser and Firefox firebug<br> </div>If you open the below attached file with Firefox firebug, you will se= e<br> </div><div class=3D"gd-grid-6 product-pricing">=A0 is insid= e <div class=3D"listing-page-bucket"> enclosure<br></div>bu= t when you parse it, the above relationship does not in the tree,<br></div>= Is there anyway I can get around this problem?<br> <br><br></div>Thanks<br><div><div><br><div><br><br><div><div><br><br></div>= </div></div></div></div></div> </blockquote></div><br></div> --047d7b15a1d12fbb2804e683975f--