salve, ho necessità di fare due xpath query in sequenza: ossia fare la seconda query sul risultato della prima.
Il problema è che xpath restituisce un array e prende in input un simpleXMLElement
ho provato questo codice
preso da qui http://stackoverflow.com/questions/1...y-to-simplexml
ma genera un xml vuoto, evidentemente l'array restituito dalla query (array di SimpleXMLElement) è indigesto alla funzione..codice:<?php// initializing or creating array $student_info = array(your array data); // creating object of SimpleXMLElement $xml_student_info = new SimpleXMLElement("<?xml version=\"1.0\"?><student_info></student_info>"); // function call to convert array to xml array_to_xml($student_info,$xml_student_info); //saving generated xml file $xml_student_info->asXML('file path and name'); // function defination to convert array to xml function array_to_xml($student_info, &$xml_student_info) { foreach($student_info as $key => $value) { if(is_array($value)) { if(!is_numeric($key)){ $subnode = $xml_student_info->addChild("$key"); array_to_xml($value, $subnode); } else{ $subnode = $xml_student_info->addChild("item$key"); array_to_xml($value, $subnode); } } else { $xml_student_info->addChild("$key",htmlspecialchars("$value")); } } } ?>
per caso c'è un modo migliore per fare due 2 query in sequenza?

Rispondi quotando