这是我正在工作的 xml 输出
<adamContent projectTypeID="10" genContentID="000002">
<metaData>
<keywordList>
<keyword>
<word>#27</word>
<relevancy>120</relevancy>
</keyword>
<keyword>
<word>#43</word>
<relevancy>114</relevancy>
</keyword>
</keywordList>
<taxonomy type="CPT">
<code>99374</code>
</taxonomy>
</metaData>
<textContent title="Description" ordinal="0" group="0">
<p>An in-depth report on the causes, diagnosis, and treatment of Alzheimer's disease.</p>
</textContent>
</adamContent>
我需要这样的输出(我想删除整个元数据节点)
<adamContent projectTypeID="10" genContentID="000002">
<textContent title="Description" ordinal="0" group="0">
<p>An in-depth report on the causes, diagnosis, and treatment of Alzheimer's disease.</p>
</textContent>
</adamContent>
这是我到目前为止尝试的 php 代码
<?php
$xmldoc = new DOMDocument();
$atvID = $xmldoc->load('000002.xml', LIBXML_NOBLANKS);
foreach($atvID as $id){
$delnode = $xmldoc->getElementsByTagName('metaData');
$xmldoc->firstChild->removeChild($delnode->item($id));
}
$xmldoc->save('000002.xml');
?>