人人人妻人人人妻人人人,99精品国产综合久久久久五月天 ,欧美白人最猛性XXXXX,日韩AV无码免费播放

News新聞

業(yè)界新聞動態(tài)、技術(shù)前沿
Who are we?

您的位置:首頁      樂道系統(tǒng)FAQ      php基于dom實現(xiàn)的圖書xml格式數(shù)據(jù)示例

php基于dom實現(xiàn)的圖書xml格式數(shù)據(jù)示例

標(biāo)簽: 發(fā)布日期:2017-02-03 00:00:00 285

本文實例講述了php基于dom實現(xiàn)的圖書xml格式數(shù)據(jù)。分享給大家供大家參考,具體如下:

<?php
 $books = array();
 $books [] = array(
 'title' => 'PHP Hacks',
 'author' => 'Jack Herrington',
 'publisher' => "O'Reilly"
 );
 $books [] = array(
 'title' => 'Podcasting Hacks',
 'author' => 'Jack Herrington',
 'publisher' => "O'Reilly"
 );
 $doc = new DOMDocument();
 $doc->formatOutput = true;
 $r = $doc->createElement( "books" );
 $doc->appendChild( $r );
 foreach( $books as $book )
 {
 $b = $doc->createElement( "book" );
 $author = $doc->createElement( "author" );
 $author->appendChild(
 $doc->createTextNode( $book['author'] )
 );
 $b->appendChild( $author );
 $title = $doc->createElement( "title" );
 $title->appendChild(
 $doc->createTextNode( $book['title'] )
 );
 $b->appendChild( $title );
 $publisher = $doc->createElement( "publisher" );
 $publisher->appendChild(
 $doc->createTextNode( $book['publisher'] )
 );
 $b->appendChild( $publisher );
 $r->appendChild( $b );
 }
 echo $doc->saveXML();
?>