[ create a new paste ] login | about

Link: http://codepad.org/QrlU5CYm    [ raw code | output | fork ]

PHP, pasted on Jun 17:
<?php

$notesxml = <<<XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<notes>
   <note>
      <to>Tove</to>
      <from>Jani</from>
      <heading>Reminder</heading>
      <body>Don't forget me this weekend!</body>
   </note>
</notes>
XML;

$notes = new SimpleXMLElement($notesxml);

$note = $notes->addChild('note');
$note->addChild('to', 'Yourself');
$note->addChild('from', 'Billy Brown');
$note->addChild('heading', 'Another note');
$note->addChild('body', 'This is the body');

echo $notes->asXML();

?>


Output:
1
2
3
4
5
6
7
8
9
<?xml version="1.0" encoding="ISO-8859-1"?>
<notes>
   <note>
      <to>Tove</to>
      <from>Jani</from>
      <heading>Reminder</heading>
      <body>Don't forget me this weekend!</body>
   </note>
<note><to>Yourself</to><from>Billy Brown</from><heading>Another note</heading><body>This is the body</body></note></notes>


Create a new paste based on this one


Comments: