// get node eva, which we will append to$eva = $xpath->query('/contacts/person[.="Eva"]')->item(0);

// create node john$john = $xml->createElement('person', 'John');

// insert john after eva// "in eva's parent node (=contacts) insert// john before eva's next node"// this also works if eva would be the last node$eva->parentNode->insertBefore($john, $eva->nextSibling);