显示简单 XML php
我正在寻找与此等效的内容:
$e= xmlwriter_open_uri("test.xml");
....
print htmlentities(xmlwriter_output_memory($e));
现在此打印允许将 xml 列表中的内容显示到表中。
但我的简单 xml(与 $dom 结合进行格式化)我不知道如何显示它。虽然这会生成正确的输出,但我希望将其放入 xml 中,如何显示下面的 xml?类似于印刷品或?
目的是将 xml 的值显示到表中。
$dom = new DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$xml = new SimpleXMLElement('<test></test>');
$one= $xml->addChild('enemy', 'yes');
$two= $xml->addChild('friend', 'maybe');
$dom->loadXML($xml->asXML());
$dom->save('test.xml');
问候
I am looking for something equivalent to this:
$e= xmlwriter_open_uri("test.xml");
....
print htmlentities(xmlwriter_output_memory($e));
now this print allows to display whats in the xml list into a table.
But my with my simple xml (combined with $dom for formatting) i have no idea how to display this. Although this generates the proper output i wish into the xml how do i display the xml below? Something similar to a print or?
The purpose is to display the values of the xml into a table.
$dom = new DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$xml = new SimpleXMLElement('<test></test>');
$one= $xml->addChild('enemy', 'yes');
$two= $xml->addChild('friend', 'maybe');
$dom->loadXML($xml->asXML());
$dom->save('test.xml');
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要对
SimpleXMLElement
进行字符串化(技术术语!)来将其加载到DOMDocument
中,事实上这是一个糟糕的主意(尽管,你被原谅了)。有关从
SimpleXMLElement
检索DOMElement
(及其DOMDocument
)的更多信息,可以在dom_import_simplexml()
。You don't need to stringify (technical term!) the
SimpleXMLElement
to load it into aDOMDocument
, in fact that's a terrible idea (though, you're forgiven).More info about retrieving a
DOMElement
(and itsDOMDocument
) from aSimpleXMLElement
can be found in the docs fordom_import_simplexml()
.