XML : make xml using php tag with attribute

After xml declaration i want make xml tag with attribute I try following code but i got error

  <?xml version="1.0" encoding="UTF-8"?>  <playlist version="1" xmlns="http://xspf.org/ns/0/">    

My php is:

  <?php            $xml_user_info = new SimpleXMLElement("<?xml version=\"1.0\"?><trackList></trackList>");          $playlist = $xml_user_info->appendChild($xml_user_info->createElement('playlist'));          $playlist->playlist->setAttribute('version','1') ;          $playlist->playlist->setAttribute('xmlns','http://xspf.org/ns/0/') ;  ?>    

Error:

( ! ) Fatal error: Call to undefined method SimpleXMLElement::appendChild() in C:\wamp\www\p\p.php on line 31

No comments:

Post a Comment