code_junkie

Special Characters in XML

Nov 11th, 2011
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <!ENTITY entity-name "entity-value">
  2. <!ENTITY raquo "&#187;">
  3.  
  4. »
  5.  
  6. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  7.  
  8. &#187; &#171; instead of &raquo; and &laquo;
  9.  
  10. &raquo; becomes &#187;
  11.  
  12. <![CDATA[&raquo;]]>
  13.  
  14. <!DOCTYPE ROOT_XML_ELEMENT [ <!ENTITY raquo "&#187;"> ]>
  15.  
  16. XmlDocument d = new XmlDocument();
  17. d.LoadXml("<foo/>");
  18. char c = (char)187;
  19. d.DocumentElement.InnerText = "Here's that character: " + c;
  20. Debug.WriteLine(d.OuterXml);
  21. d.DocumentElement.InnerText = "Here it is as an HTML entity: &raquo;";
  22. Debug.WriteLine(d.OuterXml);
  23.  
  24. <foo>Here's that character: »</foo>
  25. <foo>Here it is as an HTML entity: &raquo;</foo>
  26.  
  27. <xsl:output use-character-maps="raquo.ent"/>
  28. <xsl:character-map name="raquo.ent">
  29. <xsl:output-character character="&#187;" string="&raquo;"/>
  30. </xsl:character-map>
Add Comment
Please, Sign In to add comment