regex - How can i extract ul tag content and p tag content inside <dd> tag using regular expresstion in php -
i want extract content <dd>
tag want take p tag content , ul tag content tried preg_match_all in php take contents inside <dd>
in html page nothing html code
<dd style="display: block;"> <p>lightweight, comfy , cool - dressy shirt won\'t mind wearing!</p> <ul> <li>made of 100% cotton</li> <li>specially treated soft feel</li> <li>classically styled pointed collar , button front</li> <li>chest pocket; curved shirttail hem</li> <li>canvas taping @ inner neck</li> <li>imported</li> </ul> <div id="bvsecondarycustomerratings" style="display:none;margin-left: 15px" class="bvbrowserwebkit"> <div class="bvrrrootelement"> <div class="bvrrratingsummary bvrrsecondaryratingsummary"> <div class="bvrrratingsummary bvrrprimaryratingsummary"><div class="bvrrratingsummarystyle2"><div class="bvrrratingsummarynoreviews"> <div id="bvrrratingsummarynoreviewswriteimagelinkid" class="bvrrratingsummarylink bvrrratingsummarynoreviewswriteimagelink"> <a name="bv_trackingtag_rating_summary_2_writereview_i2613l0022" target="bvframe" href="http://reviews.childrensplace.com/4154/i2613l0022/writereview.htm?format=embedded&campaignid=bv_rating_summary_zero_reviews&sessionparams=__bvsessionparams__&return=http%3a%2f%2fwww.childrensplace.com%2fwebapp%2fwcs%2fstores%2fservlet%2fproduct_10001_10001_-1_1005476_827676_26601%257c72469%257c813599_boy%257coutfits%257cplaid%2520patrol_boy&innerreturn=http%3a%2f%2freviews.childrensplace.com%2f4154%2fi2613l0022%2freviews.htm%3fformat%3dembedded&user=__userid__&authsourcetype=__authtype__&submissionparams=__bvsubmissionparameters__&submissionurl=http%3a%2f%2fwww.childrensplace.com%2fwebapp%2fwcs%2fstores%2fservlet%2ftcpcheckuserauthenticationcmd%3flangid%3d-1%26catalogid%3d10001%26storeid%3d10001"> <img src="http://reviews.childrensplace.com/static/4154/translucent.gif" alt="write review"> </a> </div> <div id="bvrrratingsummarylinkwritefirstid" class="bvrrratingsummarylink bvrrratingsummarylinkwritefirst"> <span class="bvrrratingsummarylinkwritefirstprefix">be first review item.</span> <a name="bv_trackingtag_rating_summary_2_socialbookmarkkaboodle_i2613l0022" target="_blank" class="bvrrsocialbookmarkingsharinglink bvrrsocialbookmarkingsharinglinkkaboodle" onclick="this.href=bvreplacetokensinsocialurl(this.href);window.open(this.href,'','left=0,top=0,width=795,height=700,toolbar=1,location=0,resizable=1,scrollbars=1'); return false;" onfocus="this.href=bvreplacetokensinsocialurl(this.href);" rel="nofollow" href="http://reviews.childrensplace.com/4154/share.htm?site=kaboodle&url=http%3a%2f%2fwww.childrensplace.com%2fwebapp%2fwcs%2fstores%2fservlet%2fproduct_10001_10001_-1_1005476&title=__title__&robot=__robot__&image=http%3a%2f%2fcontent.childrensplace.com%2fwww%2fb%2ftcp%2fimages%2fstyles%2f188410_m.jpg" onmouseover="this.href=bvreplacetokensinsocialurl(this.href);"><img width="16" height="16" class="bvrrsocialbookmarklinkimage" src="http://reviews.childrensplace.com/static/4154/link-kaboodle.gif" alt="kaboodle" title="add kaboodle"></a> </div></div></div></div> </div> </div> <p class="tcp-phrase">big fashion, little prices</p> <div id="product_social_icons" style="height: 20px;"> <div class="social_icon current_social"> <div class="twitter"><iframe scrolling="no" frameborder="0" allowtransparency="true" src="http://platform.twitter.com/widgets/tweet_button.1336551279.html#_=1336767195241&count=horizontal&id=twitter-widget-0&lang=en&original_referer=http://www.childrensplace.com/webapp/wcs/stores/servlet/product_10001_10001_-1_1005476&size=m&text=the childrens place - plaid shirt&url=http://www.childrensplace.com/webapp/wcs/stores/servlet/product_10001_10001_-1_1005476" class="twitter-share-button twitter-count-horizontal" style="height: 20px; width: 90px;" title="twitter tweet button"></iframe></div> <div class="pinterest" id="pin_it"> <iframe scrolling="no" frameborder="0" src="http://pinit-cdn.pinterest.com/pinit.html?url=http://www.childrensplace.com/webapp/wcs/stores/servlet/product_10001_10001_-1_1005476&media=//content.childrensplace.com/www/b/tcp/images/cloudzoom/p/188410_p.jpg&description=plaid shirt&layout=horizontal" style="border: medium none; width: 90px; height: 20px;"></iframe> </div> <div class="fb-like-btn" id="fb-root"> <script src="//connect.facebook.net/en_us/all.js#xfbml=1"></script> <fb:like layout="button_count" show_faces="false" width="90" action="like" font="arial" colorscheme="light" fb-xfbml-state="rendered" class="fb_edge_widget_with_comment fb_iframe_widget"><span style="height: 20px; width: 76px;"><iframe id="f111d3371c" name="f5f7b234c" scrolling="no" style="border: none; overflow: hidden; height: 20px; width: 76px;" title="like content on facebook." class="fb_ltr" src="http://www.facebook.com/plugins/like.php?api_key=&locale=en_us&sdk=joey&channel_url=http%3a%2f%2fstatic.ak.facebook.com%2fconnect%2fxd_arbiter.php%3fversion%3d23%23cb%3df11898a314%26origin%3dhttp%253a%252f%252fwww.childrensplace.com%252ff210aed7%26domain%3dwww.childrensplace.com%26relation%3dparent.parent&href=http%3a%2f%2fwww.childrensplace.com%2fwebapp%2fwcs%2fstores%2fservlet%2fproduct_10001_10001_-1_1005476_827676_26601%257c72469%257c813599_boy%257coutfits%257cplaid%2520patrol_boy&node_type=link&width=90&font=arial&layout=button_count&colorscheme=light&action=like&show_faces=false&extended_social_context=false"></iframe></span></fb:like></div> </div> </div> </dd>
i googled alot figure out problem tried dom parsing client need regex parsing instead of that..
here answer doesn't tell approach ethically wrong:
$pattern = "/<dd.*?>.*?<p>(.*?)<\/p>.*?<ul>(.*?)<\/ul>/s"; if (preg_match($pattern, $html, $matches)) { echo "p-tag content: ".$matches[1]; echo "<br>"; echo "ul-tag content: ".$matches[2]; }
i tested html posted , worked.