Use of Xml CData to obtain the detailed code introduction of the original node content

黄舟
Release: 2017-03-03 11:44:20
Original
1972 people have browsed it


The use of Xml CData to obtain the details of the original node content code introduction

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>,这样就取到全部的节点内容了
Copy after login

The above is the use of Xml CData to obtain the details of the original node content code introduction. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template