Update
I thought that I had it because I had extra space in between the documentElement it was screwing up the formatting...
So instead of my xml file looking like this:
It needed to look like this:
So this makes it format all pretty for the first time when you add an element. but if you try to edit that element or add another it goes back to all in one line!!!! :glare:
So here is the code that I had now... PLEASE HELP ME!
$dom = new DomDocument();
$dom->formatOutput = true;
# Setup the objects for speech
$speech = $dom->appendChild($dom->createElement("speech"));
# Append elements to the speech XML object
$speech->appendChild($dom->createElement("id", $id));
$speech->appendChild($dom->createElement("title", $s->title));
$speech->appendChild($dom->createElement("link", $s->link));
# Setup the objects for date and append the elements
$date = $speech->appendChild($dom->createElement("date"));
$date->appendChild($dom->createElement("month", $s->month));
$date->appendChild($dom->createElement("day", $s->day));
$date->appendChild($dom->createElement("year", $s->year));
if($new){
$xml->documentElement->appendChild($xml->importNode($dom->documentElement, true));
}else{
# Search for the element with the index to be deleted
$xpath = new DOMXPath($xml) ;
$oldSpeech = $xpath->query('//speech[id="'.$id.'"]')->item(0) ;
# Still need to check to see if it wasn't found
$speech = $xml->importNode($dom->documentElement, true);
$xml->documentElement->replaceChild($speech, $oldSpeech);
}
$xml->save($filename);
print $xml->saveXML();
which outputs the first time:
<calendar>
<speech>
<id>520b31a6359be49d756bb9b9468b7209</id>
<title>test</title>
<link>test</link>
<date>
<month>0</month>
<day>1</day>
<year>2005</year>
</date>
</speech>
</calendar>
And then if i add or update another it:
<calendar>
<speech><id>520b31a6359be49d756bb9b9468b7209</id><title>testing</title><link>test</link><date><month>0</month><day>1</day><year>2005</year></date></speech>
</calendar>