How to write CData in xml

前端 未结 6 1546
谎友^
谎友^ 2020-12-06 00:09

i have an xml like :



    
             


        
6条回答
  •  醉话见心
    2020-12-06 00:41

    Do you really need it to be in CDATA, or do you just want to get the text in there in a way which won't require extra escaping in your code?

    InnerText performs whatever escaping is required, so generally I'd just use

    xnode.InnerText = Convert.ToString(sqlReader["story_status"]);
    

    ... but if you really want a CDATA node, you can create one yourself as per Nekresh's answer.

提交回复
热议问题