Using PHP, how do I get an entire subset of nodes from an XML document? I can retrieve something like:
The answer turned out to be a combination of the xpath suggestion and outputting with asXML().
Using the example given by Josh Davis:
$people = simplexml_load_string(
Jane Doe
21
John Smith
34
'
);
// get all nodes
$nodes = $people->xpath('/people/certain');
foreach ( $nodes as $node ) {
$result .= $node->asXML()."\n";
}
echo $result;