Jump to content

[SOLVED] simpleXML Errors. Not sure what the cause is...


Alex-Grim

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.