まず、xml文書内の特定の子ノード値で親ノードを検索する必要があります。次に、特定の子ノードを親ノードから別のXMLドキュメントにコピーします。例えばPHPある文書から別の文書にxmlノードをコピー
:
DESTINATION FILE: ('destination.xml')
<item>
<offerStartDate>2012-15-02</offerStartDate>
<offerEndDate>2012-19-02</offerEndDate>
<title>Item Title</title>
<rrp>14.99</rrp>
<offerPrice>9.99</offerPrice>
</item>
と
SOURCE FILE: ('source.xml')
<items>
<item>
<title>Item A</title>
<description>This is the description for Item A</description>
<id>1003</id>
<price>
<rrp>10.00</rrp>
<offerPrice>4.99</offerPrice>
</price>
<offer>
<deal>
<isLive>0</isLive>
</deal>
</offer>
</item>
<item>
<title>Item B</title>
<description>This is the description for Item B</description>
<id>1003</id>
<price>
<rrp>14.99</rrp>
<offerPrice>9.99</offerPrice>
</price>
<offer>
<deal>
<isLive>1</isLive>
</deal>
</offer>
</item>
<item>
<title>Item C</title>
<description>This is the description for Item C</description>
<id>1003</id>
<price>
<rrp>9.99</rrp>
<offerPrice>5.99</offerPrice>
</price>
<offer>
<deal>
<isLive>0</isLive>
</deal>
</offer>
</item>
私はそれが "1" に設定された子ノード<isLive>
値のしている親ノード<item>
を見つけたいです。親ノードの他の子ノードを宛先xmlにコピーします。
親ノード<item>
の子ノード<isLive>
が1に設定されている場合は、<title>
,<rrp>
および<offerPrice>
のノードとその値をコピーし、上記のように子ノードとして宛先ファイルに追加します。
正しく使用していない場合は、技術用語を教えてください。
多くのお手伝いをいただきありがとうございます。 SimpleXMLは(demo)で
私はあなたのdestination.xmlがあまりにも、項目のルートノードを持っていると仮定? – Gordon
はい、それは ' 'です。今すぐそれに取り組んでください –
echez