c# 读取xml CDATA过滤

方法一: 

string NewString=Regex.Replace("<![CDATA[你好]]>","[^\u4e00-\u9fa5]","");

方法二:

一个简单的xml,如下所示:

<?xml version="1.0" encoding="GBK"?>
<Document>
    <ChiefComplaint>
        <![CDATA[右眼视力进行性下降2年余]]>
    </ChiefComplaint>
</Document>

读取

private int ReadXml()
        {
            string responseInfo = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"
                                + @"<Document>
                                        <ChiefComplaint>
                                            <![CDATA[右眼视力进行性下降2年余]]>
                                        </ChiefComplaint>
                                    </Document>";


            XmlDocument doc = new XmlDocument();
            doc.LoadXml(responseInfo);
            string xpathChiefComplaint = "/Document/ChiefComplaint";

            XmlNode xnChiefComplaint = doc.SelectSingleNode(xpathChiefComplaint);

            string nodeValue = xnChiefComplaint.InnerText;
        }

猜你喜欢

转载自blog.csdn.net/qq_32915337/article/details/83896651
今日推荐