Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stripping bad characters for RSS feed

Status
Not open for further replies.

Jeff80

Programmer
Aug 18, 2005
9
0
0
US
I'm trying to code a script that generates a RSS feed, but the data being output keeps throwing XML parse errors. I think I've narrowed it down to possibly line-feed or carriage return throwing the error, but it might be anything.

I've been passing the data through the below code to try to get rid of the bad characters:

$str = str_replace(chr(10), "", $str);
$str = str_replace(chr(13), "", $str);
$str = htmlentitites($str);

Despite the lines above, I'm still getting XML parse errors. Any ideas?
 
Hard to tell without seeing the feed. As you said, it could be anything, though a newline character wouldn't be my first guess. Have you tried running the feed through feedvalidator.org to see if you can get a meaningful error message?
 
i can't see why carriage returns or line feeds would be bad characters. i also don't think your parser would very much like the xml to be mangled by htmlentities before being parsed. after running that function there would be no xml left as all the <> would be turned into the html equivalents.

i'm with adahacker here: we need a sample of your xml, your parsing code and the precise errors you are receiving.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top