我想选择html的图像和文本块,但我得到的只是图像块。这是我试过的xpath。
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$encoded =mb_convert_encoding($htmlFile, 'HTML-ENTITIES', "UTF-8");
$dom->loadHTML($encoded);
$finder = new DomXPath($dom);
$nodes = $finder->query("//div[@class='itemImageBlock'] | //div[@class='itemFullText']");
我没有收到任何错误,但它只返回' itemImageBlock'仅限内容。
这是文件。
<article id="k2Container" class="itemView"> <div class="itemImageBlock"> <a class="itemImage modal" rel="{handler: 'image'}" href="/media/k2/items/cache/94c48d8f62a29726ef2379021149030b_XL.jpg" title="Click to preview image"> <img src="/media/k2/items/cache/94c48d8f62a29726ef2379021149030b_M.jpg" alt="የማተሚያ ማሽን መገጣጠሚያ ፋብሪካ በባህርዳር ተከፈተ" style="width:400px; height:auto;"> </a>
</div>
<header>
<h1> የማተሚያ ማሽን መገጣጠሚያ ፋብሪካ በባህርዳር ተከፈተ </h1>
<ul>
<li>
<time datetime="07 Jun 2014 01:11"> 07 June, 2014 </time>
</li>
<li class="itemAuthor"> Written by
አበባየሁ ገበያው </li>
<li class="itemResizer"> <span>font size</span> <a href="#" id="fontDecrease">decrease font size</a> <a href="#" id="fontIncrease">increase font size</a> </li>
<li class="itemPrint"> <a rel="nofollow" href="/index.php?option=com_k2&view=item&id=14283:የማተሚያ-ማሽን-መገጣጠሚያ-ፋብሪካ-በባህርዳር-ተከፈተ&Itemid=180&tmpl=component&print=1" onclick="window.open(this.href,'printWindow','width=900,height=600,location=no,menubar=no,resizable=yes,scrollbars=yes'); return false;"> Print </a> </li>
<li class="itemEmail"> <a rel="nofollow" href="/index.php?option=com_mailto&tmpl=component&template=gk_music_free&link=aea60479c8a7ead468252d1144c79f5e1c8fd4c5" onclick="window.open(this.href,'emailWindow','width=400,height=350,location=no,menubar=no,resizable=no,scrollbars=no'); return false;"> Email </a> </li>
</ul>
</header>
<div class="itemBody"> <div class="itemFullText"> <p style="text-align: justify;">ኢትዮጵያ በኤሌክትሮኒክስ ምርቶች የራስዋ ብራንድ እንዲኖራት በጋራ እንሰራለን - የጣና ኮሙኒኬሽን ስራ አስኪያጅ<br><br>ጣና ኮሙኒኬሽን ከሳምሰንግ ኩባንያ ጋር በመተባበር፣ በባህር ዳር ከተማ የማተሚያ መሳሪያ (ፕሪንተር) መገጣጠምያ ፋብሪካ የከፈተ ሲሆን በቅርቡም ምርቶቹን ወደ ጎረቤት አገራት ለመላክ መዘጋጀቱ ተገለፀ፡፡<br>የማተሚያ ማሽን (ፕሪንተር) አካላትን ከዋናው የሳምሰንግ ኩባንያ በማስመጣት፣ የተለያዩ ሞዴል ያላቸውን ማተሚያ ማሽኖች የሚገጣጥመው ፋብሪካው፤ የተሻለ የጥራት ደረጃ ያላቸው የሳምሰንግ ፕሪንተሮችን ከኦሪጂናል የማተሚያ ቀለም ጋር ለሽያጭ እንደሚያቀርብ ታውቋል፡፡<br>የጣና ኮሙኒኬሽን ስራ አስኪያጅ አቶ ስዩም አዳሙ እንደተናገሩት፤ ከሳምሰንግ ኩባንያ ጋር በፈጠሩት ትብብር የጥሬ እቃ አቅርቦትና የባለሞያ እገዛ ያገኙ ሲሆን የተለያየ መጠንና ዋጋ ያላቸው የሳምሰንግ ማተሚያ ማሽኖች (ፕሪንተሮች) በሃገር ውስጥ ተገጣጥመው ለገበያ ሲቀርቡ በአፍሪካ የመጀመሪያው ነው፡፡ <br>ፋብሪካው በደቂቃ 20 ገጾችን ከሚያትመው 20/60 የተባለው ትንሹ ማተሚያ መሳሪያ ጀምሮ የተለያየ መጠን ያላቸው ማተሚያዎችን እየገጣጠመ በሳምሰንግ ብራንድ ለገበያ እንደሚያቀርብ ሥራ አስኪያጁ ተናግረዋል፡፡ <br>“ጣና እና ሳምሰንግ ትብብራቸውን የጀመሩት የማተሚያ መሳሪያዎች አካላትን በመገጣጠም ይሁን እንጂ በዚህ ብቻ ተወስኖ አይቆምም፤ በሀገሪቱ የኤሌክትሮኒክስ ምርቶች ትብብራቸው የሚቀጥል ሲሆን ጣና ኮሙኒኬሽን በሀገር ውስጥ ያሉ ግብዓቶችን በመጠቀም ሁሉንም ማተሚያ አካላት እዚሁ ለመፈብረክ አቅዶ እየሰራ ነው፡፡” ብለዋል - ሥራ አስኪያጁ፡፡ ሳምሰንግ ለምርት ለጥራት ባለው ከፍተኛ ግምት፣ ፋብሪካው በቴክኖሎጂ ምርት የልቀት ማዕከል እንዲሆን የሚሰራ ሲሆን በኤሌክትሮኒክስ ምርቶችም ኢትዮጵያ የራስዋን ብራንድ ፈጥራ ወደአለማቀፍ ገበያ እንድትገባ ትብብሩ ይቀጥላል ተብሏል፡፡ ሳምሰንግ ስማርት ፎኖችን፣ ፍሪጆችን፣ ፍላሾችን፣ ታብሌቶችንና ካሜራዎችን በማምረት በዓለም ላይ ስመገናና ሲሆን ማተምያዎችን (ፕሪንተሮች) በማምረትም በዓለም በሁለተኛ ደረጃ ላይ እንደሚገኝ የሳምሰንግ ኤሌክትሮኒክስ ኩባንያ፣ የምስራቅ አፍሪካ ተወካይ አቶ ታዲዮስ ሃወል ገልፀዋል፡፡ <br><br></p> </div>
<div class="itemBottom">
<div class="itemRatingBlock"> <span>Rate this item</span>
<div class="itemRatingForm">
<ul class="itemRatingList">
<li class="itemCurrentRating" id="itemCurrentRating14283" style="width:60%;"></li>
<li> <a href="#" rel="14283" title="1 star out of 5" class="one-star">1</a> </li>
<li> <a href="#" rel="14283" title="2 stars out of 5" class="two-stars">2</a> </li>
<li> <a href="#" rel="14283" title="3 stars out of 5" class="three-stars">3</a> </li>
<li> <a href="#" rel="14283" title="4 stars out of 5" class="four-stars">4</a> </li>
<li> <a href="#" rel="14283" title="5 stars out of 5" class="five-stars">5</a> </li>
</ul>
<div id="itemRatingLog14283" class="itemRatingLog">(1 Vote)</div>
</div>
</div>
</div>
<div class="itemLinks">
<div class="itemHits"> Read <strong>32</strong> times </div>
<div class="itemCategory"> <span>Published in</span> <a href="/index.php?option=com_k2&view=itemlist&task=category&id=1:ዜና&Itemid=180">ዜና</a> </div>
<div class="itemSocialSharing">
<div class="itemTwitterButton"> <iframe id="twitter-widget-0" scrolling="no" frameborder="0" allowtransparency="true" src="http://platform.twitter.com/widgets/tweet_button.1401325387.html#_=1402150124688&count=horizontal&id=twitter-widget-0&lang=en&original_referer=http%3A%2F%2Fwww.addisadmassnews.com%2Findex.php%3Foption%3Dcom_k2%26view%3Ditem%26id%3D14283%3A%25E1%258B%25A8%25E1%2588%259B%25E1%2589%25B0%25E1%2588%259A%25E1%258B%25AB-%25E1%2588%259B%25E1%2588%25BD%25E1%258A%2595-%25E1%2588%2598%25E1%258C%2588%25E1%258C%25A3%25E1%258C%25A0%25E1%2588%259A%25E1%258B%25AB-%25E1%258D%258B%25E1%2589%25A5%25E1%2588%25AA%25E1%258A%25AB-%25E1%2589%25&size=m&text=%E1%8B%A8%E1%88%9B%E1%89%B0%E1%88%9A%E1%8B%AB%20%E1%88%9B%E1%88%BD%E1%8A%95%20%E1%88%98%E1%8C%88%E1%8C%A3%E1%8C%A0%E1%88%9A%E1%8B%AB%20%E1%8D%8B%E1%89%A5%E1%88%AA%E1%8A%AB%20%E1%89%A0%E1%89%A3%E1%88%85%E1%88%AD%E1%8B%B3%E1%88%AD%20%E1%89%B0%E1%8A%A8%E1%8D%88%E1%89%B0&url=http%3A%2F%2Fwww.addisadmassnews.com%2Findex.php%3Foption%3Dcom_k2%26view%3Ditem%26id%3D14283%3A%2525E1%25258B%2525A8%2525E1%252588%25259B%2525E1%252589%2525B0%2525E1%252588%25259A%2525E1%25258B%2525AB-%2525E1%252588%25259B%2525E1%252588%2525BD%2525E1%25258A%252595-%2525E1%252588%252598%2525E1%25258C%252588%2525E1%25258C%2525A3%2525E1%25258C%2525A0%2525E1%252588%25259A%2525E1%25258B%2525AB-%2525E1%25258D%25258B%2525E1%252589%2525A5%2525E1%252588%2525AA%2525E1%25258A%2525AB-%2525E1%252589%2525" class="twitter-share-button twitter-tweet-button twitter-share-button twitter-count-horizontal" title="Twitter Tweet Button" data-twttr-rendered="true" style="width: 110px; height: 20px;"></iframe>
<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
</div>
<div class="itemFacebookButton">
<div id="fb-root" class=" fb_reset"><div style="position: absolute; top: -10000px; height: 0px; width: 0px;"><div><iframe name="fb_xdm_frame_http" frameborder="0" allowtransparency="true" scrolling="no" id="fb_xdm_frame_http" aria-hidden="true" title="Facebook Cross Domain Communication Frame" tabindex="-1" src="http://static.ak.facebook.com/connect/xd_arbiter/V80PAcvrynR.js?version=41#channel=f16269a9f4&origin=http%3A%2F%2Fwww.addisadmassnews.com" style="border: none;"></iframe><iframe name="fb_xdm_frame_https" frameborder="0" allowtransparency="true" scrolling="no" id="fb_xdm_frame_https" aria-hidden="true" title="Facebook Cross Domain Communication Frame" tabindex="-1" src="https://s-static.ak.facebook.com/connect/xd_arbiter/V80PAcvrynR.js?version=41#channel=f16269a9f4&origin=http%3A%2F%2Fwww.addisadmassnews.com" style="border: none;"></iframe></div></div><div style="position: absolute; top: -10000px; height: 0px; width: 0px;"><div><iframe name="feb177cc4" frameborder="0" allowtransparency="true" scrolling="no" src="https://www.facebook.com/connect/ping?client_id=177111755694317&domain=www.addisadmassnews.com&origin=1&redirect_uri=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter%2FV80PAcvrynR.js%3Fversion%3D41%23cb%3Dfccf3d6f8%26domain%3Dwww.addisadmassnews.com%26origin%3Dhttp%253A%252F%252Fwww.addisadmassnews.com%252Ff16269a9f4%26relation%3Dparent&response_type=token%2Csigned_request%2Ccode&sdk=joey" style="display: none;"></iframe></div></div></div>
<script type="text/javascript">
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#appId=177111755694317&xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-like fb_iframe_widget" data-send="false" data-width="260" data-show-faces="true" fb-xfbml-state="rendered" fb-iframe-plugin-query="app_id=177111755694317&href=http%3A%2F%2Fwww.addisadmassnews.com%2Findex.php%3Foption%3Dcom_k2%26view%3Ditem%26id%3D14283%3A%25E1%258B%25A8%25E1%2588%259B%25E1%2589%25B0%25E1%2588%259A%25E1%258B%25AB-%25E1%2588%259B%25E1%2588%25BD%25E1%258A%2595-%25E1%2588%2598%25E1%258C%2588%25E1%258C%25A3%25E1%258C%25A0%25E1%2588%259A%25E1%258B%25AB-%25E1%258D%258B%25E1%2589%25A5%25E1%2588%25AA%25E1%258A%25AB-%25E1%2589%25&locale=en_US&sdk=joey&send=false&show_faces=true&width=260"><span style="vertical-align: bottom; width: 260px; height: 20px;"><iframe name="f10643d97c" width="260px" height="1000px" frameborder="0" allowtransparency="true" scrolling="no" title="fb:like Facebook Social Plugin" src="http://www.facebook.com/plugins/like.php?app_id=177111755694317&channel=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter%2FV80PAcvrynR.js%3Fversion%3D41%23cb%3Df3d7ba96e%26domain%3Dwww.addisadmassnews.com%26origin%3Dhttp%253A%252F%252Fwww.addisadmassnews.com%252Ff16269a9f4%26relation%3Dparent.parent&href=http%3A%2F%2Fwww.addisadmassnews.com%2Findex.php%3Foption%3Dcom_k2%26view%3Ditem%26id%3D14283%3A%25E1%258B%25A8%25E1%2588%259B%25E1%2589%25B0%25E1%2588%259A%25E1%258B%25AB-%25E1%2588%259B%25E1%2588%25BD%25E1%258A%2595-%25E1%2588%2598%25E1%258C%2588%25E1%258C%25A3%25E1%258C%25A0%25E1%2588%259A%25E1%258B%25AB-%25E1%258D%258B%25E1%2589%25A5%25E1%2588%25AA%25E1%258A%25AB-%25E1%2589%25&locale=en_US&sdk=joey&send=false&show_faces=true&width=260" style="border: none; visibility: visible; width: 260px; height: 20px;" class=""></iframe></span></div>
</div>
<div class="itemGooglePlusOneButton">
<div id="___plusone_0" style="text-indent: 0px; margin: 0px; padding: 0px; border-style: none; float: none; line-height: normal; font-size: 1px; vertical-align: baseline; display: inline-block; width: 120px; height: 24px; background: transparent;"><iframe frameborder="0" hspace="0" marginheight="0" marginwidth="0" scrolling="no" style="position: static; top: 0px; width: 120px; margin: 0px; border-style: none; left: 0px; visibility: visible; height: 24px;" tabindex="0" vspace="0" width="100%" id="I0_1402150123251" name="I0_1402150123251" src="https://apis.google.com/_/+1/fastbutton?usegapi=1&annotation=inline&width=120&hl=en&origin=http%3A%2F%2Fwww.addisadmassnews.com&url=http%3A%2F%2Fwww.addisadmassnews.com%2Findex.php%3Foption%3Dcom_k2%26view%3Ditem%26id%3D14283%3A%25E1%258B%25A8%25E1%2588%259B%25E1%2589%25B0%25E1%2588%259A%25E1%258B%25AB-%25E1%2588%259B%25E1%2588%25BD%25E1%258A%2595-%25E1%2588%2598%25E1%258C%2588%25E1%258C%25A3%25E1%258C%25A0%25E1%2588%259A%25E1%258B%25AB-%25E1%258D%258B%25E1%2589%25A5%25E1%2588%25AA%25E1%258A%25AB-%25E1%2589%25&gsrc=3p&ic=1&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.am.j51B_lWWUeE.O%2Fm%3D__features__%2Fam%3DEQ%2Frt%3Dj%2Fd%3D1%2Fz%3Dzcms%2Frs%3DAItRSTP5V6qZCx3Gd8uatYwL5Pn85fd8rw#_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe%2C_renderstart%2Concircled%2Cdrefresh%2Cerefresh&id=I0_1402150123251&parent=http%3A%2F%2Fwww.addisadmassnews.com&pfname=&rpctoken=37307084" data-gapiattached="true" title="+1"></iframe></div>
<script type="text/javascript">
(function() {
window.___gcfg = {lang: 'en'}; // Define button default language here
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</div>
</div>
</div>
<div class="itemNavigation"> <span>More in this category:</span>
<a class="itemPrevious" href="/index.php?option=com_k2&view=item&id=14282:የኢትዮጵያ-አየር-መንገድ-በትርፋማነቱ-ከዓለም-18ኛ-ሆነ&Itemid=180">« የኢትዮጵያ አየር መንገድ በትርፋማነቱ ከዓለም 18ኛ ሆነ</a>
<a class="itemNext" href="/index.php?option=com_k2&view=item&id=14284:ማህበራቱ-ለፓትርያርኩ-ቅሬታችንን-እንዳናቀርብ-ተከለከልን-አሉ&Itemid=180">ማህበራቱ ለፓትርያርኩ ቅሬታችንን እንዳናቀርብ ተከለከልን አሉ »</a>
</div>
</div>
<a class="itemBackToTop" href="/index.php?option=com_k2&view=item&id=14283:የማተሚያ-ማሽን-መገጣጠሚያ-ፋብሪካ-በባህርዳር-ተከፈተ&Itemid=180#"> back to top </a>
</article>