Heim > Backend-Entwicklung > PHP-Tutorial > php生成XML文档源代码_PHP教程

php生成XML文档源代码_PHP教程

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Freigeben: 2016-07-13 17:40:24
Original
951 Leute haben es durchsucht

生成XML源代码:

<span style="color: rgb(0, 0, 0);">    $dom <span style="color: rgb(0, 0, 204);">=</span> new DOMDocument<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br>     if<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">!</span><span style="color: rgb(0, 0, 204);">$</span>dom<span style="color: rgb(0, 0, 204);">)</span><br>     <span style="color: rgb(0, 0, 204);">{</span><br>         printf<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(255, 0, 255);">"构造XML失败! "</span><span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br>         return <span style="color: rgb(0, 0, 204);">-</span>3999<span style="color: rgb(0, 0, 204);">;</span><br>     <span style="color: rgb(0, 0, 204);">}</span><br> <br>     if<span style="color: rgb(0, 0, 204);">(</span>FALSE <span style="color: rgb(0, 0, 204);">=</span><span style="color: rgb(0, 0, 204);">=</span> <span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">$</span>dom<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">></span>load<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">$</span>filename<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">)</span><br>     <span style="color: rgb(0, 0, 204);">{</span><br>         add_root<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br>         if<span style="color: rgb(0, 0, 204);">(</span>FALSE <span style="color: rgb(0, 0, 204);">=</span><span style="color: rgb(0, 0, 204);">=</span> <span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">$</span>dom<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">></span>load<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">$</span>filename<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">)</span><br>         <span style="color: rgb(0, 0, 204);">{</span><br>             return <span style="color: rgb(0, 0, 204);">-</span>3999<span style="color: rgb(0, 0, 204);">;</span><br>         <span style="color: rgb(0, 0, 204);">}</span><br>     <span style="color: rgb(0, 0, 204);">}</span><br> <br>     <span style="color: rgb(0, 0, 204);">/</span><span style="color: rgb(0, 0, 204);">/引用root根节点</span><br>     $f_node <span style="color: rgb(0, 0, 204);">=</span> $dom<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">></span>getElementsByTagName<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">$</span>parent_node<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">></span>item<span style="color: rgb(0, 0, 204);">(</span>0<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span> <br>     if<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">!</span><span style="color: rgb(0, 0, 204);">$</span>f_node<span style="color: rgb(0, 0, 204);">)</span><br>     <span style="color: rgb(0, 0, 204);">{</span><br>         $root <span style="color: rgb(0, 0, 204);">=</span> $dom<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">></span>getElementsByTagName<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(255, 0, 255);">root</span><span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">></span>item<span style="color: rgb(0, 0, 204);">(</span>0<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span> <br>         <span style="color: rgb(0, 0, 204);">/</span><span style="color: rgb(0, 0, 204);">/创建父节点</span><br>         $f_node <span style="color: rgb(0, 0, 204);">=</span> $dom<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">></span>createElement<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">$</span>parent_node<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br>         $f_node <span style="color: rgb(0, 0, 204);">=</span> $root<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">></span>appendChild<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">$</span>f_node<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br>     <span style="color: rgb(0, 0, 204);">}</span>    <br>     <span style="color: rgb(0, 0, 204);">/</span><span style="color: rgb(0, 0, 204);">/创建节点</span><br>     $item_node <span style="color: rgb(0, 0, 204);">=</span> $dom<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">></span>createElement<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">$</span>node<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br>     $item_node <span style="color: rgb(0, 0, 204);">=</span> $f_node<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">></span>appendChild<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">$</span>item_node<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br>     $item_value <span style="color: rgb(0, 0, 204);">=</span> $dom<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">></span>createTextNode<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">$</span><span style="color: rgb(255, 0, 0);">value</span><span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br>     $item_node<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">></span>appendChild<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">$</span>item_value<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br> </span>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/486219.htmlTechArticle生成XML源代码: $dom = new DOMDocument ( ) ; if ( ! $ dom ) { printf ( "构造XML失败!" ) ; return - 3999 ; } if ( FALSE = = ( $ dom - load ( $ filename ) ) ) { add_root (...
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Aktuelle Ausgaben
PHP-Datenerfassung?
Aus 1970-01-01 08:00:00
0
0
0
PHP-Erweiterung intl
Aus 1970-01-01 08:00:00
0
0
0
Wie man PHP gut lernt
Aus 1970-01-01 08:00:00
0
0
0
Mehrere PHP-Versionen
Aus 1970-01-01 08:00:00
0
0
0
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage