La mia richiesta è semplice: mi servirebbe sapere come aggiungere un nodo, ad un elemento del DomDocument dopo aver fatto una query xpath:
Codice PHP:
public function append($string, $path = '//html/body') {
$xpath = new DOMXPath ( $this->response );
$elements = $xpath->evaluate ( $path, $this->response );
for($i = 0; $i < $elements->length; $i ++) {
if (! $string instanceof DOMNode) {
$string = $this->response->createDocumentFragment ()->appendXML ( $string );
}
$elements->item ( $i )->appendChild ( $this->response->importNode ( $string, true ) );
}
}
quando vado a recuperare l'elemento $this->response, non trovo il nuovo elemento che sarebbe dovuto essere appeso.
Spero sia stato chiaro