Posted by alu on Wed 2nd May 14:48
download | new post
- $doc = new DOMDocument();
- $dom->preserveWhiteSpace = false;
- $doc->formatOutput = true;
- $doc->load('xml/bookings.xml');
- $booking = $doc->createElement('booking');
- $childNode = $doc->createElement('company');
- $textNode = $doc->createTextNode('One more company');
- $childNode->appendChild($textNode);
- $booking->appendChild($childNode);
- $childNode = $doc->createElement('starts');
- $textNode = $doc->createTextNode('2008-01-01 22:22:22');
- $childNode->appendChild($textNode);
- $booking->appendChild($childNode);
- $childNode = $doc->createElement('ends');
- $textNode = $doc->createTextNode('2008-01-01 22:22:22');
- $childNode->appendChild($textNode);
- $booking->appendChild($childNode);
- $childNode = $doc->createElement('rooms');
- $textNode = $doc->createTextNode('1,2,3');
- $childNode->appendChild($textNode);
- $booking->appendChild($childNode);
- $childNode = $doc->createElement('attenders');
- $textNode = $doc->createTextNode('34');
- $childNode->appendChild($textNode);
- $booking->appendChild($childNode);
- $childNode = $doc->createElement('booker');
- $textNode = $doc->createTextNode('alu');
- $childNode->appendChild($textNode);
- $booking->appendChild($childNode);
- $childNode = $doc->createElement('contact');
- $textNode = $doc->createTextNode('njet');
- $childNode->appendChild($textNode);
- $booking->appendChild($childNode);
- $root = $doc->getElementsByTagName('bookings');
- $root = $root->item(0);
- $root->appendChild($booking);
- $doc->save('xml/bookings.xml');
Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.