PHP读取xml之cdata讲解
2014-04-18 14:11
155 查看
实例:
xss.xml
<?xml version="1.0" encoding="UTF-8"?>
<filters>
<filter>
<id>1</id>
<rule><![CDATA[(?:"[^"]*[^-]?>)|(?:[^\w\s]\s*\/>)|(?:>")]]></rule>
<description>finds html breaking injections including whitespace attacks</description>
</filter>
</filters>
1.使用$result = simplexml_load_file ( 'xss.xml', 'SimpleXMLElement', LIBXML_NOCDATA );
2.使用$result = getElementByTagName("rule")读取文本,再使用str_replace()用空格替换<![CDATA[( && )]]>,最后使用trim(string,charlist)[charlist=""]删除字符串两端的空格!
xss.xml
<?xml version="1.0" encoding="UTF-8"?>
<filters>
<filter>
<id>1</id>
<rule><![CDATA[(?:"[^"]*[^-]?>)|(?:[^\w\s]\s*\/>)|(?:>")]]></rule>
<description>finds html breaking injections including whitespace attacks</description>
</filter>
</filters>
1.使用$result = simplexml_load_file ( 'xss.xml', 'SimpleXMLElement', LIBXML_NOCDATA );
2.使用$result = getElementByTagName("rule")读取文本,再使用str_replace()用空格替换<![CDATA[( && )]]>,最后使用trim(string,charlist)[charlist=""]删除字符串两端的空格!
相关文章推荐
- PHP读取xml方法讲解
- PHP读取XML数据中CDATA内数值
- php读取xml中cdata部分方法
- PHP读取xml方法介绍
- php xmlreader simplexml等读取xml
- php4/5使用Dom方式读取和解析和创建XML简单教程
- 云服务PHP读取XML问题失败的问题解决方法
- PHP 操作 XML 文件 - 读取、显示
- JAXB读取包含有CDATA的XML文件及相关异常解决
- php解析带CDATA的XML
- PHP 操作 XML 文件 - 读取、显示
- PHP读取、解析XML的方法.
- PHP读取XML
- PHP解析带CDATA的XML方法
- php生成xml时添加CDATA标签的方法
- PHP中使用xmlreader读取xml数据示例
- php读取XML的常见方法实例总结
- php操作XML,读取数据和写入数据的方法
- php生成xml时添加CDATA标签的方法
- PHP处理XML文档,没有CDATA部分数据处理