Re: A simple question: how to protect '>'
"Bill Kearney" <[email protected]>
| Newsgroups | gmane.network.syndication.rss.devel |
|---|---|
| Message-ID | <[email protected]> |
> How do you protect the '>' and '<' signs in XML? I am
> using PHP to parse my documents.
There are five symbols you need to handle.
&<'>" and they should be encoded as & < ' > and "
Those are the five default entities that must be encoded. Other
symbols can be encoded using unicode numbers. Just make sure you
don't double-encode unless it's actually needed.
The only time you'd need to double encode would be if you actually
intended to show one of the symbols.
<description>This is <b>bold</> text</description>
Would give a sentence with the word bold in HTML bold.
If, however, you wanted to talk about the encoding itself you'd need
to double encode:
<description>To show bold text you'd use
&lt;b&gt;bold&lt;/&gt;.</description>
This gives you the sentence "To show bold text you'd use <b>bold</b>."
Tricky but not all that hard once you get the idea.
-Bill Kearney
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/rss-dev/
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/