Hello,

I try to read a xml file with this schema:

- <item>
<title>some text</title>
<link>link</link>
- <description>
text ok
<br />
I can't see this text </description>
<imedia:thumbURL>link</imedia:thumbURL>
</item>

When I write:
echo $rss_channel["ITEMS"][$i]["DESCRIPTION"];
I can see text ok, but from <br /> I can't see nothing.

I tried to use somethink like eregi_replace("<br />", "\n", $var); but with no effect. Could you help me ?

And for <imedia:thumbURL> what channel shoud I use ?

$rss_channel["ITEMS"][$i]["imedia:thumbURL"]; or $rss_channel["ITEMS"][$i]["thumbURL"]; are not working.

Thank you!

Looks like your XML is invalid.
The XML1.0 Specs I believe specifies that all literal < and > be replaced with the htmlentity equivalents ( &lt; and &gt; ).
All other HTML entities be replaced with their html special character equivalients. ie: htmlspecialchars() in PHP.

If you have an event based parser (such as a SAX) parsing the XML, they it may be able to overcome the malformed XML stanzas. But if you're using an Object based parser such as DOM, It will choke.
What RSS parser are you using?

You can use regex to remove the <br />, what you have should work, but that would mean you're parsing the XML twice. Not the best for performance.

If you don't mind the double parse, you can also replace whats between <description> and </description> with valid CDATA.

eg:

$xml = preg_replace(
	"/<description>(.*?)<\/description>/is", 
	"<description><[CDATA[$1]]></description>", 
	$xml
);

note: eregi_ is alot slower then its preg_ equivalent.

This article has been dead for over six months. Start a new discussion instead.