如何<title>在此XML字符串中删除元素?
$input=
'<items>dfd jdh flkdjf
<title>My Test Title
</title>....
<store>my store 1</store>
</items>.....';
$output=
'<items>dfd jdh flkdjf
....
<store>my store 1</store>
</items>.....';
Run Code Online (Sandbox Code Playgroud)
谢谢
SimpleXML的
$str = '<items>1<title>lalala</title><others>...</others></items>';
$xml = simplexml_load_string($str);
unset($xml->children()->title);
$output = str_replace("<?xml version=\"1.0\"?>\n", '', $xml->asXml());
Run Code Online (Sandbox Code Playgroud)