如何删除XML字符串中的元素?

Yos*_*sef 1 php regex xml

如何<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)

谢谢

ajr*_*eal 7

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)