私はこれに困惑だし、面白い部分は、私は正常にこのコード何度も使用してきましたさ... SimpleXMLはできませんXMLからの既存のノードに文字列を結合します。たぶん私は」は、PHPを経由して、XMLにノードを追加し、(newsku)</p> <p>私の目的は、新しいノードを作成することです
...何が起こることは、私は新しいノードのない元のXMLを取得することである
<?php
header('Content-Type: text/html; charset=UTF-8');
error_reporting(E_ALL);
// Import test xml
$products = simplexml_load_file("http://test.com/xml/customer.xml");
foreach($products->xpath("product") as $p) {
$p->addChild("newsku", "NEW" . $p->sku);
}
$products->asXML('test.xml');
echo 'test XML files are updated';
?>
:ここ
は、XMLです:<products>
<product>
<id>3</id>
<name><![CDATA[ΜΙΚΡΟΦΩΝΟ SAMSON G-TRACK]]></name>
<manufacturer><![CDATA[SAMSON]]></manufacturer>
<sku><![CDATA[550.SAM.060]]></sku>
<description_greek><![CDATA[Samson G-Track - large diaphragm USB studio
condenser microphone (USB bus-powered), built-in audio interface and mixer,
allows simultaneous input of vocals and guitar, bass, or keyboard while also
providing monitoring through an on-board headphone output. Specifications: mic
and instrument/line gain control with clip LED, stereo input jacks for (3.5mm
stereo-jack) instrument or line level signal, stereo headphone jack for zero
latency monitoring with level control, 3-position headphone switch for stereo,
mono and computer monitoring. USB bus-powered. Includes desktop microphone
stand, audio I/O cables, USB cables and Cakewalk Sonar LE software. Optional
shockmount available.
]]></description_greek>
<short_description_greek><![CDATA[Samson G-Track - large diaphragm USB studio
condenser microphone (USB bus-powered)]]></short_description_greek>
<price>155.00</price>
<msrp>185.00</msrp>
<instock>no</instock>
<images total="2">
<image_1>http://test.com/media/catalog/product/5/5/550.sam.060-mi-
01.jpg</image_1>
<image_2>http://test.com/media/catalog/product/5/5/550.sam.060-mi-
02.jpg</image_2>
</images>
</product>
</products>
そして、ここに私のコードです私はこれを他の多くのXMLファイルでも問題なく使用して以来、本当にばかげたことをしています...
アイデア?
ありがとうございます!
を - https://3v4l.org/5JnEv –
こんにちはローレンスは、なぜこのため、他のXMLファイルとではないため、この作業を行います1? –
'http:// test.com/xml/customer.xml'からのフェッチと' test.xml':/への保存が繰り返されるだけです。 –