Alex-Grim Posted December 16, 2007 Share Posted December 16, 2007 The path should be correct, so i doubts that's the problem, and the file is a valid rss feed: <?xml version="1.0" encoding="ISO-8859-1" ?> <rss version="2.0"> <channel> <title>LinuxIntro.com</title> <description>A great place to learn Linux! Featuring Video lessons, examples, and more</description> <link>http://LinuxIntro.com/</link> <language>en-us</language> <webMaster>Alex-Grim@msn.com</webMaster> <item> <title>Dark Elysium's website's are down for a while</title> <description>The both AlexGrim.com and GrimMusic.com are down for a while.</description> <link>http://GrimMusic.com</link> <guid isPermaLink="true">http://GrimMusic.com</guid> </item> <item> <title>Register as an official Linux user!</title> <description>If you use linux, you can add yourself to the registered user db.</description> <link>http://counter.li.org</link> <guid isPermaLink="true">http://counter.li.org</guid> </item> </channel> </rss> Here's my error: Warning: SimpleXMLElement::__construct() [function.SimpleXMLElement---construct]: Entity: line 3: parser error : Start tag expected, '<' not found in /var/www/html/Alex/LinuxIntro/terminal/CreateContent2.php on line 12 Warning: SimpleXMLElement::__construct() [function.SimpleXMLElement---construct]: in /var/www/html/Alex/LinuxIntro/terminal/CreateContent2.php on line 12 Warning: SimpleXMLElement::__construct() [function.SimpleXMLElement---construct]: ^ in /var/www/html/Alex/LinuxIntro/terminal/CreateContent2.php on line 12 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /var/www/html/Alex/LinuxIntro/terminal/CreateContent2.php:12 Stack trace: #0 /var/www/html/Alex/LinuxIntro/terminal/CreateContent2.php(12): SimpleXMLElement->__construct('??') #1 {main} thrown in /var/www/html/Alex/LinuxIntro/terminal/CreateContent2.php on line 12 Thanx in advance, i'd really like to fix this one. Quote Link to comment Share on other sites More sharing options...
Alex-Grim Posted December 16, 2007 Author Share Posted December 16, 2007 I changed my code and amended this: if (file_exists('NewArticles.rss')) { $xmlFile = simplexml_load_file('NewArticles.rss'); print_r($xml); } else { exit('Failed to open test.xml.'); } And it's finding the file, it just can't read it... Quote Link to comment Share on other sites More sharing options...
Alex-Grim Posted December 16, 2007 Author Share Posted December 16, 2007 Changed code to this... $xml = new SimpleXMLElement("NewArticles.rss",null,true); $item = $xml->addChild("item"); $item->addChild("title", $_POST['title']); $item->addChild("description", substr($_POST['contents'],0,666)); $item->addChild("link","http://LinuxIntro.com?con=".$_POST['name']); $item->addChild("guid","http://LinuxIntro.com?con=".$_POST['name']); echo $xmlFile->asXML(); And now i'm only getting this error: Fatal error: Call to a member function asXML() on a non-object in /var/www/html/Alex/LinuxIntro/terminal/CreateContent2.php on line 26 Quote Link to comment Share on other sites More sharing options...
teng84 Posted December 16, 2007 Share Posted December 16, 2007 it says this asXML() is not in your class or maybe that is not a function but var only try to check Quote Link to comment Share on other sites More sharing options...
Alex-Grim Posted December 16, 2007 Author Share Posted December 16, 2007 I fixed it, here's the resulting code: $xml = new SimpleXMLElement("../rss/NewArticles.rss",null,true); $item = $xml->channel[0]->addChild("item"); $item->addChild("title", $_POST['title']); $item->addChild("description", substr($_POST['contents'],0,666)); $item->addChild("link","http://LinuxIntro.com?con=".$_POST['name']); $item->addChild("guid","http://LinuxIntro.com?con=".$_POST['name']); echo $xml->asXML(); //fwrite($,$); Btw, i love your avatar. Now to work on getting it to write to my rss file... Quote Link to comment Share on other sites More sharing options...
teng84 Posted December 16, 2007 Share Posted December 16, 2007 told yah.. thanks.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.