0
큰 나무가 있는데, 2 html 태그 사이의 id (h2 # ftc와 h2 # ftd 사이) 사이의 일부 html을 구문 분석하려고했습니다. 간단한 html dom , 올바른 방법으로 그것을하는 방법? 내 코드가 빈 데이터를 얻는다. 감사.php 간단한 html dom, id로 2 html 태그 사이의 일부 html을 구문 분석합니다.
require ("simple_html_dom.php");
$result=<<<EOT
<ul>
<h2 id="fta">tree1</h2>
<li>nod a</li>
<li>nod b</li>
<li>nod c</li>
<h2 id="ftb">tree2</h2>
<li>nod d</li>
<li>nod e</li>
<li>nod f</li>
<h2 id="ftc">tree3</h2>
<li>nod g</li>
<li>nod h</li>
<h2 id="ftd">tree4</h2>
<li>nod i</li>
<li>nod j</li>
<li>nod k</li>
<li>nod l</li>
</ul>
EOT;
$html = str_get_html($result);
foreach($html->find("ul") as $st) {
if($st->find("h2[id=ftc]")){continue;}
echo $st;
if($st->find("h2[id=ftd]")){break;}
}
그리고 난 단지 출력합니다 : 당신은 대신 자신의 솔루션을 출시 할 시도하는 PHP와 함께 제공되는 DOM 클래스를 사용하여 오프 훨씬 좋을 것
<h2 id="ftc">tree3</h2>
<li>nod g</li>
<li>nod h</li>