php - 解析具有 HTML 值的 XML 数据
问题描述
你好,
我有一个返回 XML 数据但以 HTMl 作为内容的端点,
到目前为止,使用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);
}
退货
"summary":"INTRODUCTION: This appeal borders on the Law of Contract.FACTS: 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:-(a) one hundred million naira as general damages for malicious breach of contract and negligent conduct;(b) sixty-four million, two hundred and fifty thousand, nine hundred and twenty naira as special damages;(c) one million, five hundred thousand naira only being the cost of this action; and(d) 10% interest per annum on the judgment sum, from the date of judgment until liquidation.The appellant denied the claim and on exchange of pleadings...
再次提问
我想在删除 XML 标签的同时保留数据中的 HTML 标签
请注意 这是一个完整的 XML,其结构无法预测,我想提取 XML 中的所有值,而不仅仅是部分
解决方案
推荐阅读
- azure-data-factory-2 - Azure Data flow 新分支数据如何流动
- html - 将错误文本的间距构建到输入组中
- r - 合并 R - VLOOKUP 等价物?
- angular - 在量角器测试期间,离开页面然后返回中断 waitForAngularEnabled()
- laravel-lighthouse - 如何创建具有 3 个或更多嵌套关系的突变?
- python - Tensorflow - 多标签分类损失缓慢下降/根本没有变化
- javascript - JS:将 xml 数据转换为点数组表示法
- javascript - 如何简化全屏元素的javascript代码?
- php - 我如何使用“选定”属性
- reporting-services - SSRS 表达式 - 显示字段中的值取决于另一个字段