 |
 |
Handling <br> in RSS (PHP)
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2001
Status:
Offline
|
|
Alright, this one has me pulling my hair out...
I'm working on some PHP scripts to turn web pages into RSS feeds. I slice up all the data and get the item title, link, aritcle, and date out of them and parse them like they need to be. Now, the trouble is when I go to replace a few things with a <br> or <p>. When I do a str_replace() and the selected content gets replaced with a <br>, NetNewsWire tells me that the feed does not exist. It still does...the content just changled slightly. I believe it's trying to interpret the < and > as XML items and isn't telling me the right error message. (After all I can SEE the .rss file!) Alright..so I use < and > or htmlentities("<br>") instead. When I do that, the < and > symbols show up in the feed, which is also not what I want.
So my options are a) broken or b) angle brackets in my feed, both of which don't give me the simple new line in the feed description that I want. I see other feeds that use <br> and <p> in them, though...how are they doing it? Different encoding? Also...I run the page source through htmlspecialchars() before outputting it, and it makes <br>'s into <br>, and the symbols don't show up; it creates a new line like it should.
Why are my concatenated < and > (or < and >) any different than what htmlspecialchars() outputs for those symbols?
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Dec 2000
Location: sj ca
Status:
Offline
|
|
I don't think <br> is allowed in the RSS. If NetNewsWire interpreted the <*> as XML, it was right to do so. I presume you're using the RSS 1 spec (much simpler than the 2.0). If so, you might want to read the documentation at http://my.netscape.com/publish/forma...spec-0.91.html.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status:
Offline
|
|
<br> isn't valid XML because there's no closing tag. Try <br/> instead.
You'll have the same issue with things like <img> and <input> tags.
|
Geekspiff - generating spiffdiddlee software since before you began paying attention.
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2001
Status:
Offline
|
|
I tried <br /> (that's br-space-slash), and it had the same broken effect... it shouldn't even be interpreting what's inside the <description> tags as XML, should it? There's just HTML there, anyway.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Dec 2000
Location: sj ca
Status:
Offline
|
|
Originally posted by macgyvr64:
I tried <br /> (that's br-space-slash), and it had the same broken effect... it shouldn't even be interpreting what's inside the <description> tags as XML, should it? There's just HTML there, anyway.
Actually, it should be interpreting what's inside the <description> tag, and no, it's not HTML. It's just plain text. Again, I refer you to the relevant section of the DTD, which states:
Code:
<!ELEMENT description (#PCDATA)>
where "PCDATA" means "parsed character data". So any reader that uses a validating parser will in fact parse what's inside a <description>.
I think the real solution is to not use <br> (or <br />), but "\n".
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2001
Status:
Offline
|
|
Using \n puts a carriage return in the source if the XML, but it's ignored by NetNewsWire (the HTML I'm parsing is filled with \n's and none of them show up in the feed)
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|