0
xmlファイルに別の要素を追加しようとしています。 これは今作成したものです。ここでXMLを作成するPHPが正しく生成されないファイル
flipsnack>
<title>Book 1</title>
<date>6-6-2016</date>
<link>google.com</link>
<embed>this is hetml code</embed>
<order>1</order>
<show>1</show>
<flipsnack>
<title/>
<link>hotmail.com</link>
<embed>html code all the way</embed>
<order>2</order>
<postdate/>
<show>1</show>
</flipsnack>
</flipsnack>
が、私はそれがあるべきだと思うものです....ここで
<?xml version="1.0" encoding="UTF-8"?>
<flipsnack>
<book>
<title>Book 1</title>
<date>6-6-2016</date>
<link>google.com</link>
<embed>this is hetml code</embed>
<order>1</order>
<show>1</show>
</book>
<book>
<title>Book 1</title>
<date>6-6-2016</date>
<link>google.com</link>
<embed>this is hetml code</embed>
<order>1</order>
<show>1</show>
</book>
</flipsnack>
は私のPHPコードです:
$title=$_POST["post"];
$date=$_POST["date"];
$link=$_POST["link"];
$html=$_POST["html"];
$order=$_POST["order"];
$show=$_POST["show"];
$xml = simplexml_load_file("db.xml");
$sxe = new SimpleXMLElement($xml->asXML());
$newItem = $sxe->addChild("flipsnack");
$newItem->addChild("title", $title);
$newItem->addChild("link", $link);
$newItem->addChild("embed", $html);
$newItem->addChild("order", $order);
$newItem->addChild("postdate", $postdate);
$newItem->addChild("show", $show);
$sxe->asXML("db.xml");
私は何をそのから取得する方法はかなりスタンドの下にいけません今私はそれをしたいと思っていますか?誰か私にある方向を教えてもらえますか?
あなたのPHPを別にしてください – zanderwar
@Zanderwar>更新 – Kelly