Php DOMDocument禁用字符转义

Php DOMDocument禁用字符转义,php,xml,json,Php,Xml,Json,我正在尝试禁用DOMDocument字符转义 因此,当我们从JSON获得节点时,就像下面这样: “某物”:“shouldnotescape” 我希望它以xml格式生成完全相同的输出: 相反,我得到: 我已经尝试过关闭substituteElements和resolveExternals,还尝试过$this->document->saveXML($this->document->documentElement)getAttribute('value'); 输出: Warning: DOMDoc

我正在尝试禁用DOMDocument字符转义

因此,当我们从JSON获得节点时,就像下面这样:
“某物”:“shouldnotescape”

我希望它以xml格式生成完全相同的输出:
相反,我得到:

我已经尝试过关闭substituteElements和resolveExternals,还尝试过
$this->document->saveXML($this->document->documentElement)

我不是在加载XML,而是在遍历JSON树并创建DomeElement。每个元素上的值在保存之前都是非转义的,因此我认为,通过DOMDocument应该可以实现这一点。

这将是无效的XML。所以这是不可能的

例如:

<?php
$dom = new DOMDocument();
$dom->loadXml('<something value="<>shouldnotescape"/>');
documentElement->getAttribute('value');
输出:

Warning: DOMDocument::loadXML(): Unescaped '<' not allowed in attributes values in Entity, line: 1 in /tmp/... on line 3    
Warning: DOMDocument::loadXML(): attributes construct error in Entity, line: 1 in /tmp/... on line 3
string(17) "<>shouldnotescape"
string(17)“shouldnotescape”

感谢您的回答,我现在所做的只是在整个xml上调用htmlspecialchars\u decode将其取回。(这太傻了)。在你问为什么之前,这是学校的项目,这就是为什么。
string(17) "<>shouldnotescape"