如何在XML字符串之后打印它';使用PHP简单XML将成为一个对象

如何在XML字符串之后打印它';使用PHP简单XML将成为一个对象,php,simplexml,Php,Simplexml,这基本上就是我要做的: $xml = '<root><item attr="1"><notes>item 1 notes</notes></item><item attr="2"><notes>item 2 notes</notes></item></root>'; $xmlObject = simplexml_load_string(xml); //The XML Inf

这基本上就是我要做的:

$xml = '<root><item attr="1"><notes>item 1 notes</notes></item><item attr="2"><notes>item 2 notes</notes></item></root>';

$xmlObject = simplexml_load_string(xml);

//The XML Info will be modified and updated via loops and other stuff in here.

$updatedXml = $xmlObject converted back to string
$xml='item 1 notesitem 2 notes';
$xmlObject=simplexml\u加载\u字符串(xml);
//XML信息将通过这里的循环和其他内容进行修改和更新。
$updatedXml=$xmlObject转换回字符串
为了澄清这一点,我将在PHP中将XML格式的字符串转换为一个简单的XML对象,然后在此之间对XML对象进行修改和更新

我搞不懂的是如何将它恢复为字符串格式


谢谢你的帮助

使用
asXML
函数: