PHP怎么插入數(shù)據(jù)庫(kù)

字號(hào):


    php生成xml時(shí)添加CDATA標(biāo)簽方法非常的簡(jiǎn)單,因?yàn)槭且粋€(gè)在xml中可以存儲(chǔ)各種內(nèi)容的標(biāo)簽了,下面整理了一個(gè)例子希望對(duì)各位有幫助。
    貼上代碼留住傷疤,不要把<![CDATA[ $text]]>當(dāng)成前后綴,其實(shí)它可以是標(biāo)簽。
    代碼如下:
    <?php
    $dom = new DOMDocument("1.0");
    // display document in browser as plain text
    // for readability purposes
    header("Content-Type: text/plain");
    // create root element
    $root = $dom->createElement("toppings");
    $dom->appendChild($root);
    // create child element
    $item = $dom->createElement("item");
    $root->appendChild($item);
    // create text node
    $text = $dom->createTextNode("pepperoni");
    $item->appendChild($text);
    // create attribute node
    $price = $dom->createAttribute("price");
    $item->appendChild($price);
    // create attribute value node
    $priceValue = $dom->createTextNode("4");
    $price->appendChild($priceValue);
    // create CDATA section
    $cdata = $dom->createCDATASection(" Customer requests that pizza be sliced into 16 square pieces ");
    $root->appendChild($cdata);
    // create PI
    $pi = $dom->createProcessingInstruction("pizza", "bake()");
    $root->appendChild($pi);
    // save and display tree
    echo $dom->saveXML();
    ?>