vbscript create-convert xml with special characters -


i'm creating xml file in .vbs file node values following,

  <car>david's</car>   <company>mannar & co.</company> 

while parsing xml, find issues &, etc.

i want convert all possible xml special characters encoded characters(with a function or something) while parsing original content.

thanking you.

based on comment of op here version made myself, couldn't find reliable one, think covers possible ascii characters

function html_encode(byval string)   dim tmp,    tmp = string   = 160 255     tmp = replace(tmp, chr(i), "&#" & & ";")   next   tmp = replace(tmp, chr(34), "&quot;")   tmp = replace(tmp, chr(39), "&apos;")   tmp = replace(tmp, chr(60), "&lt;")   tmp = replace(tmp, chr(62), "&gt;")   tmp = replace(tmp, chr(38), "&amp;")   tmp = replace(tmp, chr(32), "&nbsp;")   html_encode = tmp end function  function html_decode(byval encodedstring)   dim tmp,   tmp = encodedstring   tmp = replace(tmp, "&quot;", chr(34) )   tmp = replace(tmp, "&apos;", chr(39))   tmp = replace(tmp, "&lt;"  , chr(60) )   tmp = replace(tmp, "&gt;"  , chr(62) )   tmp = replace(tmp, "&amp;" , chr(38) )   tmp = replace(tmp, "&nbsp;", chr(32) )   = 160 255     tmp = replace(tmp, "&#" & & ";", chr(i))   next   html_decode = tmp end function  str = "this !@#± & test!" wscript.echo html_encode(str) '=> this&nbsp;!@#&amp;#177;&nbsp;is&nbsp;a&nbsp;&amp;&nbsp;test! wscript.echo html_decode(html_encode(str)) '=> !@#± & test! 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -