Friday, 16 August 2013

How to keep object tag when parsing HTML Content use SimpleHTMLDom

How to keep object tag when parsing HTML Content use SimpleHTMLDom

I want to keep all content from div with class content(keep all original
html format include object flash video). But when i use SimpleHTMLDom to
parsing i don't get all content that i want .
//File test.html
<div class="content">
<div style="text-align:center;">
<object id="fpt_player_3548_0"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
height="296" width="470"><param
value="http://st.f2.vnecdn.net/f/v37/fptplayer_embed.swf"
name="movie"><param value="high" name="quality"><param
value="transparent" name="wmode"><param
value="xmlPath=http://vnexpress.net/video/vne-info/id/3548/type/2&amp;colorAux=0x0099ff&amp;colorBorder=0x333333&amp;colorMain=0xffffff&amp;local=embed&amp;mAuto=false&amp;autoHide=false&amp;trackurl=&amp;tracktype=video"
name="flashvars"><param value="true"
name="allowfullscreen"><param value="always"
name="allowScriptAccess"><embed id="fpt_player_3548_0"
name="fpt_player_3548_0"
src="http://st.f2.vnecdn.net/f/v37/fptplayer_embed.swf"
pluginspage="http://www.macromedia.com/go/getflashplayer"
wmode="transparent" allowscriptaccess="always"
allowfullscreen="true" type="application/x-shockwave-flash"
flashvars="xmlPath=http://vnexpress.net/video/vne-info/id/3548/type/2&amp;colorAux=0x0099ff&amp;colorBorder=0x333333&amp;colorMain=0xffffff&amp;local=embed&amp;mAuto=false&amp;autoHide=false&amp;trackurl=&amp;tracktype=video"
height="296" width="470">
</object>
</div>
<p class="Normal">
<em>Something</em>
More contents
</p>
</div>
//Code to parsing HTML using SimpleHTMLDom
$html = file_get_html('test.html');
// find all div tags with class=content
foreach($html->find('div.content') as $e)
echo $e->innertext . '<br>';
//This output i have (object tag hidden)
<div style="text-align:center;">
<div id="video-3548" data-component="true" data-component-type="video"
data-component-value="3548" data-component-typevideo="2"
style="display:none;">
</div>
</div>
<p class="Normal">
<em>Something</em>
More contents
</p>

No comments:

Post a Comment