现在的位置: 首页 > 综合 > 正文

simplexml_load_string解析xml数据

2012年11月26日 ⁄ 综合 ⁄ 共 299字 ⁄ 字号 评论关闭

使用简单解析xml内容,测试过,要求标签一定要一开一闭,不然无法解析出信息来:

$data = "<html><title>study</title><body><p>good good study</p> , day day up!</body></html>";

$res = simplexml_load_string($data);

print_r($res);

  结果:

SimpleXMLElement Object

(

    [title] => study

    [body] => SimpleXMLElement Object

        (

            [p] => good good study

        )

)

支持标签嵌套,但一定要闭合标签。

抱歉!评论已关闭.