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 &amp; &lt; &apos; &gt; and &quot;

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 &lt;b&gt;bold&lt;/&gt; 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 
&amp;lt;b&amp;gt;bold&amp;lt;/&amp;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/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.