SimpleXml转换为字符串 [英] SimpleXml to string
本文介绍了SimpleXml转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有从PHP SimpleXMLElement
生成字符串的函数?
Is there any function that makes string from PHP SimpleXMLElement
?
推荐答案
You can use the SimpleXMLElement::asXML()
method to accomplish this:
$string = "<element><child>Hello World</child></element>";
$xml = new SimpleXMLElement($string);
// The entire XML tree as a string:
// "<element><child>Hello World</child></element>"
$xml->asXML();
// Just the child node as a string:
// "<child>Hello World</child>"
$xml->child->asXML();
这篇关于SimpleXml转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文