Visualizzazione dei risultati da 1 a 1 su 1
  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2011
    Messaggi
    590

    2 xpath query in sequenza

    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
    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"));
            }
        }
    }
    
    
    ?>
    ma genera un xml vuoto, evidentemente l'array restituito dalla query (array di SimpleXMLElement) è indigesto alla funzione..
    per caso c'è un modo migliore per fare due 2 query in sequenza?
    Ultima modifica di jimbo0; 22-06-2014 a 02:42

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.