SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Zealot
    Join Date
    May 2003
    somewhere on the Earth
    0 Post(s)
    0 Thread(s)

    xml question about storing special chars

    Hey I've got several questions about XML. Hope you can give me some idea.

    1. html entities.
    I know <, >, ', " and & should be converted to their html equivalents when stored in a xml file. but what about when & appears in a url address? for example:
    	<attr url=''> or another one</attr>
    should the & in the query part of the url be converted to &amp; also?

    2. CDATA
    CDATA sections begin with a <![CDATA[ and end with a ]]>. and it's said that I could store original <, >, ', " and &.

    but what about when the user inputs contains ]]> which is the close tag of the CDATA section? for example:
    	<cdata><![CDATA][ so I can put < > ' " & here. but wait what if I put a "]]>" here? ]]></cdata>
    3. quotes in tags and attributes
    I know attributes value must be within two single/double quotes like:
    	<attr1 value='some value here within two single quotes' />
    	<attr2 value="or some within two double quotes" />
    so when there is any ' or " in the value string, it should be converted to its html equivalent. but what about leaving a double quote " unchanged when it's within two single quotes ', and leaving a single quote' unchanged when it's within two double quotes " ? like the following:
    	<attr1 value='a double quote " here within two single quotes' />
    	<attr2 value="or a single quote ' within two double quotes" />
    and also, if the quotes are in tags, like:
    	<quote>JC said, " should I do this 'BAD' thing here?"</quote>
    I guess it might be ok to leave them there as they are, or am I totally wrong and I should change all of them in whatever place to &quot; and ' respectively?
    Last edited by zjcboy; Jul 13, 2004 at 07:10.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts