Revision: 37829
Updated Code
at December 18, 2010 06:19 by adrianparr
Updated Code
// http://xml.silmaril.ie/authors/specials/ function replaceSpecialXmlChars($str:String):String { var regExp:RegExp; regExp = /&/g; $str = $str.replace(regExp, "&"); regExp = /</g; $str = $str.replace(regExp, "<"); regExp = />/g; $str = $str.replace(regExp, ">"); regExp = /"/g; $str = $str.replace(regExp, """); regExp = /'/g; $str = $str.replace(regExp, "'"); return $str; } var myStr:String = "<&>\"'<&>\"'"; trace(myStr); trace(replaceSpecialXmlChars(myStr)); // OUTPUT // <&>"' // <&>"'
Revision: 37828
Updated Code
at December 18, 2010 06:19 by adrianparr
Updated Code
// http://xml.silmaril.ie/authors/specials/ function replaceSpecialXmlChars($str:String):String { var regExp:RegExp; regExp = /&/g; $str = $str.replace(regExp, "&"); regExp = /</g; $str = $str.replace(regExp, "<"); regExp = />/g; $str = $str.replace(regExp, ">"); regExp = /\"/g; $str = $str.replace(regExp, """); regExp = /'/g; $str = $str.replace(regExp, "'"); return $str; } var myStr:String = "<&>\"'<&>\"'"; trace(myStr); trace(replaceSpecialXmlChars(myStr)); // OUTPUT // <&>"' // <&>"'
Revision: 37827
Updated Code
at December 18, 2010 06:17 by adrianparr
Updated Code
// http://xml.silmaril.ie/authors/specials/ function replaceSpecialXmlChars($str:String):String { var regExp:RegExp; regExp = /&/g; $str = $str.replace(regExp, "&"); regExp = /</g; $str = $str.replace(regExp, "<"); regExp = />/g; $str = $str.replace(regExp, ">"); regExp = /"/g; $str = $str.replace(regExp, """); regExp = /'/g; $str = $str.replace(regExp, "'"); return $str; } var myStr:String = "<&>\"'<&>\"'"; trace(myStr); trace(replaceSpecialXmlChars(myStr)); // OUTPUT // <&>"' // <&>"'
Revision: 37826
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 17, 2010 23:00 by adrianparr
Initial Code
// http://xml.silmaril.ie/authors/specials/ function replaceSpecialXmlChars($str:String):String { $str = $str.replace("&", "&"); $str = $str.replace("<", "<"); $str = $str.replace(">", ">"); $str = $str.replace("\"", """); $str = $str.replace("'", "'"); return $str; } var myStr:String = "<&>\"'"; trace(myStr); trace(replaceSpecialXmlChars(myStr)); // OUTPUT // <&>"' // <&>"'
Initial URL
http://xml.silmaril.ie/authors/specials/
Initial Description
These five characters should be replaced with their HTML entity names before being used in XML, otherwise they may cause the XML to be invalid.
Initial Title
AS3 Replace Special XML Characters with Entity Names (Partial Set)
Initial Tags
regex, replace, xml, regexp
Initial Language
ActionScript 3