SimpleXML搜索子项并检索所有节点

More or less I need guidance to move forward with this ..

Have a page that displays each node in a container (does stuff to it)

XML

<archive>
<data id="1111">
<name>Name</name>
<text>Lots of stuff and things</text>
<etc>Etc</etc>
</data>
<data id="2222">
<name>Name</name>
<text>Different stuff and things</text>
<etc>Etc</etc>
</data>
<data id="3333">
<name>Name</name>
<text>More stuff and things</text>
<etc>Etc</etc>
</data>
// and so on
</archive>

This portion takes the XML and echos the values etc ..

  $master = array_slice($xml_get->xpath('data'), $start_page, 25);
  $master = array_reverse($master);

  foreach($master as $arc) {

    $last_name  = $arc[0]->name;
    $last_data  = $arc[0]->data;
    $last_etc   = $arc[0]->etc;

// does stuff with values

}

What I want to do is have a search field that takes that search keyword and searches all the children and then foreach every node+children that matches.

Honestly I just would appreciate some direction on how to accomplish this. I know how to individually grab a node via the id= but after that .. need guidance.

As a quick sample, to search the <text> element using XPath (I've altered the sample data you give to show the difference in what it selects)

$data = '<archive>
    <data id="1111">
        <name>Name</name>
        <text>Lots of stuff and things</text>
        <etc>Etc</etc>
    </data>
    <data id="2222">
        <name>Name</name>
        <text>Different stuff and things</text>
        <etc>Etc</etc>
    </data>
    <data id="3333">
        <name>Name</name>
        <text>More stuff and other things</text>
        <etc>Etc</etc>
    </data>
</archive>';

$xml_get = simplexml_load_string($data);

$textSearch = "stuff and things";

$matches = $xml_get->xpath('//data[contains(text,"'.$textSearch.'")]');
foreach($matches as $arc) {

    echo "text=".$arc->text.PHP_EOL;

}

Outputs..

text=Lots of stuff and things
text=Different stuff and things

The XPath - //data[contains(text,"'.$textSearch.'")] basically says to find any <data> element which has a <text> element which has a value that contains the string being searched for. You can alter which field it uses by just changing text