PHP Fatal error: Call to a member function asXML() on a non
Posted: Sat Mar 19, 2011 1:01 pm
Hey guys,
im trying to do a simplexml_load_file and it is giving me this error...(PHP Fatal error: Call to a member function asXML() on a non-object)..my xml code is pretty basic so im not sure what is going wrong. here is the code
<?php
//$mid = mysql_insert_id();
//$mq = mysql_query("SELECT * FROM updates WHERE userid='".$userid."' AND id='".$mid."'");
//$mrow = mysql_fetch_assoc($mq);
//$mpath = $mrow['musicpath'];
$filename = "/var/www/members/1/playlist.xml";
$xml = simplexml_load_file($filename);
$sxe = new SimpleXMLElement($xml->asXML());
$track = $sxe->addChild("track");
$track->addChild("location", "test");
$track->addChild("title", "test");
echo "<br />";
$sxe->asXML("/var/www/members/1/playlist.xml");
?>
im trying to do a simplexml_load_file and it is giving me this error...(PHP Fatal error: Call to a member function asXML() on a non-object)..my xml code is pretty basic so im not sure what is going wrong. here is the code
<?php
//$mid = mysql_insert_id();
//$mq = mysql_query("SELECT * FROM updates WHERE userid='".$userid."' AND id='".$mid."'");
//$mrow = mysql_fetch_assoc($mq);
//$mpath = $mrow['musicpath'];
$filename = "/var/www/members/1/playlist.xml";
$xml = simplexml_load_file($filename);
$sxe = new SimpleXMLElement($xml->asXML());
$track = $sxe->addChild("track");
$track->addChild("location", "test");
$track->addChild("title", "test");
echo "<br />";
$sxe->asXML("/var/www/members/1/playlist.xml");
?>