可能重复:
如何使用 PHP 解析和处理 HTML?
我有 HTML 代码,我需要获取第一个 DIV 块
<div class="right-catalog-item"><b>Accessories 1</b></div>
在我需要从第一个 DIV 块获取后,获取内部 DIV 块
<div style="margin-left: 10px;">
从此代码:
<div class="right-catalog-item"><b>Accessories 1</b></div>
<div style="margin-left: 10px;">
<div class="right-catalog-item"><a href="/catalog/type/25/">item 1</a></div>
<div class="right-catalog-item"><a href="/catalog/type/10/">item 2</a></div>
<div class="right-catalog-item"><a href="/catalog/type/60/">item 3</a></div>
</div>
<div class="right-catalog-item"><a href="/catalog/type/2/"><b>Accessories 1</b></a>
</div>
<div class="right-catalog-item"><a href="/catalog/type/1/"><b>Accessories 1</b></a></div>
<div class="right-catalog-item"><a href="/catalog/type/27/"><b>Accessories 1</b></a></div>
<div class="right-catalog-item"><a href="/catalog/type/19/"><b>Accessories 1</b></a></div>
<div class="right-catalog-item"><a href="/catalog/type/5/"><b>Accessories 1</b></a></div>
<div class="right-catalog-item"><a href="/catalog/type/4/"><b>Accessories 1</b></a></div>
<div class="right-catalog-item"><a href="/catalog/type/70/"><b>Accessories 1</b></a></div>
<div class="right-catalog-item"><a href="/catalog/type/12/"><b>Accessories 1</b></a></div>