c# - Encoding xml and saving to SQL Server -
have web application let's paste text , save database.
text had € (euro currency) symbol , once got database, crashed while parsing xml in sql. reason invalid character.
i solved using c# replace € € in web api. xml contains € , gets parsed sql. @ saved row in database , shows €. great!
i go web application , pull text saved. expect see "€52.9mm" instead, see "52.9mm".
i hit f12, refresh , see indeed retrieve "€52.9mm" what's stored in database. ui shows "52.9mm".
for kicks, change value in database € 52.9mm. refresh of ui shows "€52.9mm".
would practical solution save text in database € 52.9mm?
if works, how save in format how in xml? after gets parsed sql, gets saved €52.9mm.
is there better solution?
best way use cdata wrapping html inside xml tag element. dont need worry escaping or converting non-xml safe characters.
now haven't shown detail on constructing xml file lets take stadard xelement. save content cdata write..
xdocument.add(new xelement("myhtml", new xcdata("<p>my html content</p>"));
cdata
cdata sections may occur anywhere character data may occur; used escape blocks of text containing characters otherwise recognized markup. cdata sections begin string
<![cdata[, end string]]>
Comments
Post a Comment