floricele_navarro
New Member
I have a php function inside one of my classes that simply creates an XML file of all of the objects. This is the code:\[code\]function writeXML(){ //LOAD PROFILE //print "Profiles: <br>"; //$pro = new Profile(); $profileArray = $this->getAll(); //var_dump($profileArray); //CHECK TO SEE IF THE XML FILE EXISTS IN THE LIBRARY/CONFIGURATION if(file_exists($_SESSION['ini'][rootPath] . "v/p.xml")){ unlink($_SESSION['ini'][rootPath] . "v/p.xml"); } //CREATE XML FILE //CREATE ROOT NODE $doc = new DOMDocument("1.0"); $doc->formatOutput = true; //CREATE ROOT NODE print "Creating nodes"; $root = $doc->createElement("profiles"); $root = $doc->appendChild($root); //ADD NODES //print "<br>Creating children"; foreach($profileArray as $member){ //AS WE CYCLE THROUGH THE ARRAY GET THE ARRAY OF OBJECT PARAMETERS $memberArray = $member->toArray(); //var_dump($memberArray); //CREATE MEMBER NODE TO ROOT $person = $doc->createElement("profile"); $person = $root->appendChild($person); //CREATE CHILD NODES FOR MEMBER /* * ID IS NOT NEEDED FOR IOS APP $id = $doc->createElement("ID"); $id = $person->appendChild($id); $idValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($member->get_id()); $idValue = $id->appendChild($idValue); */ $lastName = $doc->createElement("lastName"); $lastName = $person->appendChild($lastName); //$lastNameValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($member->get_lname()); $lastNameValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($memberArray['lastName']); $lastNameValue = http://stackoverflow.com/questions/13710682/$lastName->appendChild($lastNameValue); $firstName = $doc->createElement("firstName"); $firstName = $person->appendChild($firstName); $firstNameValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($memberArray['firstName']); //$firstNameValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($member->get_fname()); $firstNameValue = $firstName->appendChild($firstNameValue); $mobile = $doc->createElement("mobile"); $mobile = $person->appendChild($mobile); $mobileValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($memberArray['mobile']); //$mobileValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($member->get_mobile()); $mobileValue = $mobile->appendChild($mobileValue); $phone = $doc->createElement("phone"); $phone = $person->appendChild($phone); $phoneValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($memberArray['phone']); //$phoneValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($member->get_phone()); $phoneValue = $phone->appendChild($phoneValue); $email = $doc->createElement("email"); $email = $person->appendChild($email); $emailValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($memberArray['email']); //$emailValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($member->get_email()); $emailValue = $email->appendChild($emailValue); $altEmail = $doc->createElement("altEmail"); $altEmail = $person->appendChild($altEmail); $altEmailValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($memberArray['altEmail']); //$altEmailValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($member->get_altemail()); $altEmailValue = $altEmail->appendChild($altEmailValue); $street = $doc->createElement("address"); $street = $person->appendChild($street); $streetValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($memberArray['street']); //$streetValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($member->get_street()); $streetValue = $street->appendChild($streetValue); $city = $doc->createElement("city"); $city = $person->appendChild($city); $cityValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($memberArray['city']); //$cityValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($member->get_city()); $cityValue = $city->appendChild($cityValue); $state = $doc->createElement("state"); $state = $person->appendChild($state); $stateValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($memberArray['state']); //$stateValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($member->get_state()); $stateValue = $state->appendChild($stateValue); $zip = $doc->createElement("zip"); $zip = $person->appendChild($zip); $zipValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($memberArray['zip']); //$zipValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($member->get_zip()); $zipValue = $zip->appendChild($zipValue); $image = $doc->createElement("image"); $image = $person->appendChild($image); $imageValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($memberArray['image']); $imageValue = http://stackoverflow.com/questions/13710682/$image->appendChild($imageValue); $titles = $doc->createElement("title"); $titles = $person->appendChild($titles); $titlesValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($memberArray['title']); //$titlesValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($member->get_field5()); $titlesvalue = $titles->appendChild($titlesValue); $group = $doc->createElement("group"); $group = $person->appendChild($group); $groupValue = http://stackoverflow.com/questions/13710682/$doc->createTextNode($memberArray['group']); $groupVAlue = http://stackoverflow.com/questions/13710682/$person->appendChild($groupValue); } print"<br>Saving XML<br><br>"; $xml_string = $doc->saveXML(); print "XML<br>"; print $xml_string; print "<br>"; print "Path: " . $_SESSION['ini']['rootPath'] . "public_html/v/p.xml"; //if($doc->save($_SESSION['ini']['htmlPath'] . "v/p.xml")) return true; //else return false; print "Bytes: " . $doc->save($_SESSION['ini']['rootPath'] . "public_html/v/p.xml"); }\[/code\]I really need another set of eyes on this as the \[code\]saveXML\[/code\] completes and even spits out the \[code\]$xml_string\[/code\] to the screen. However, the \[code\]$doc->save\[/code\] does not show anything at all. Ideas?