<source>
<job>
<title><![CDATA[newsTitle]]></title>
<date><![CDATA[newsTo]]></date>
.......
现在,我需要添加
<publisher>abc</publisher>
<publisherurl>http://google.com</publisherurl>
就在<source>
标签之后。我尝试了下面的代码,但它是在源标记之后添加的!
$doc = new DOMDocument();
$doc->load('C:\test.xml', LIBXML_NOBLANKS);
$xpath = new DOMXPath($doc);
$hrefs = $xpath->evaluate("/source");
$href = $hrefs->item(0);
$link = $doc->createElement("publisher","abc");
$href->appendChild($link);
$link = $doc->createElement("publisherurl","www.google.com");
$href->appendChild($link);
print $doc->save('C:\test.xml');
如何在源代码之后添加这些节点?