Home > Backend Development > PHP Tutorial > 【分享】PHP 读取XML自动过滤 CDATA

【分享】PHP 读取XML自动过滤 CDATA

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 14:04:53
Original
1149 people have browsed it

// 在开发过程中遇到对XML获取时候加载 CDATA 无法读取内部的数值

$content = simplexml_load_string('');
echo (string) $content;

$foo = simplexml_load_string('');
echo (string) $foo->content;

// 通过下面的方法自动过滤 CDATA 内部参数
$content = simplexml_load_string('', null, LIBXML_NOCDATA);

希望能帮到大家


回复讨论(解决方案)

谢谢分享!

不过,你示例的代码都能输出正确的结果
不知道你分享的是什么

挺好!$content = simplexml_load_string('', null, LIBXML_NOCDATA);

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