Xml CData的使用 获取原始的节点内容的详情代码介绍
string withoutCdata ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<result><data><script>alert(\"\");</script></data></result>"; XmlDocument doc = new XmlDocument(); doc.LoadXml(withoutCdata); string value = doc.SelectSingleNode("result/data").InnerText; //value = alert(\"\");,其中“<script></script>“会被处理掉,得不到全部的节点内容 string withCdata = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<result><data><![CDATA[<script>alert(\"\");</script>]]></data></result>"; doc.LoadXml(withCdata); string oriValue = doc.SelectSingleNode("result/data").InnerText; //oriVale = <script>alert(\"\");</script>,这样就取到全部的节点内容了
以上就是Xml CData的使用 获取原始的节点内容的详情代码介绍的内容,更多相关内容请关注PHP中文网(www.php.cn)!