使用PHP设置从页面获取div内容的开始和停止

file.html

<div class="a">
    <div class="ac"> ssssssssss </div>
    <div class="aa"> hhhhhhh </div>
    <p> dddd </p>
    <p class="ss">dddddddd </p>
    <span> ssssssss </span>
    <div class="sa"> <p> sss </p></div>
    <div class="ssa"> <p> sss </p></div>
    <div class="sa"> <span> sss </span></div>

    <!-- stop all if it comes to this div dont show anything under -->
    <div class="stop-here"> </div>
    <div class="sssa"> <p> sss </p></div>
    <div class="ssssa"> <p> sss </p></div>

</div>

i have a file.html and i want to get all tags inside a div, and i want it to stop getting contents once it sees a div with class "stop-here"

$html = new DOMDocument();
@$html->loadHtmlFile('file.htm');
$xpath = new DOMXPath( $html );
$nodelistfulldesc = $xpath->query( "//div[@class='a']" );

foreach ($nodelistfulldesc as $fdn)
{
    $m .= $fdn->nodeValue;
}

this is the php am using to get all content, but cant stop it.

You can use such xpath to take all nodes in div[@class='a'] before div[@class="stop-here"]

`//div[@class='a']/*[following::div[@class="stop-here"]]`

update it works very easy

div[@class='a']/* takes all children of the node

[following::div[@class="stop-here"]] selects among them those for which div[@class="stop-here"] is ahead