解析具有HTML值的XML数据

时间:2018-05-08 08:41:13

标签: php json xml simplexml simplexml-load-string

您好

我有一个端点,它返回XML数据,但HTMl作为内容,

到目前为止,使用header返回一个条纹版本,即删除了所有标签

示例数据

simplexml_load_string($result, "SimpleXMLElement", LIBXML_NOCDATA);

解析我的方法

<JUDGMENT>
    <summary>INTRODUCTION: <br />This appeal borders on the Law of Contract.<br /><br />FACTS: <br />From the statement of claim filed by the plaintiff (respondent) breach of contract and negligence were said to have been committed against it, by the appellant. Amongst other prayers, the respondent claimed:-<br />(a) one hundred million naira as general damages for malicious breach of contract and negligent conduct;<br />(b) sixty-four million, two hundred and fifty thousand, nine hundred and twenty naira as special damages;<br /></summary>
</JUDGMENT>

返回

protected function scaffoldXML($result)
    {
        $xml = simplexml_load_string($result, "SimpleXMLElement", LIBXML_NOCDATA);
        return $json = json_encode($xml);
    }

再次提问

我希望在删除XML标记时保留数据中的HTML标记

请注意 它是一个完整的XML,其结构无法预测,我想提取XML中的所有值,而不仅仅是

部分

0 个答案:

没有答案