Re: [xslt] Splitting a result into subtrees

Nick Wellnhofer schrieb:

I see, only the standard DOM functions are available. Then it's a bit
more complicated. Something like that:

Thanks a lot, Nick! I'm taking the liberty to present a working example:

$xml_str = "<Urmel><Eins/><Zwei/><Drei>Juhu</Drei></Urmel>";
$doc = new domdocument;
$doc->loadxml( $xml_str);
echo $doc->savexml();

$xpath = new domxpath( $doc);
$drei = $xpath->query( '/Urmel/Drei')->item(0);

$subtree = new domdocument;
$subtree->appendChild( $subtree->importNode( $drei, TRUE));
echo $subtree->savexml();

Can't believe I haven't discovered this before. I thought it was
missing, although it is documented.

But that's basic DOM manipulation and doesn't really belong on this

True. Thanks nonetheless.

Michael Ludwig

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]