|
導(dǎo)讀網(wǎng)頁(yè)的本質(zhì)就是超級(jí)文本標(biāo)記語(yǔ)言,通過(guò)結(jié)合使用其他的Web技術(shù)(如:腳本語(yǔ)言、公共網(wǎng)關(guān)接口、組件等),可以創(chuàng)造出功能強(qiáng)大的網(wǎng)頁(yè)。因而,超級(jí)文本標(biāo)記語(yǔ)言是萬(wàn)維網(wǎng)(Web)編程的基礎(chǔ),也就是說(shuō)萬(wàn)維網(wǎng)是建立... 網(wǎng)頁(yè)的本質(zhì)就是超級(jí)文本標(biāo)記語(yǔ)言,通過(guò)結(jié)合使用其他的Web技術(shù)(如:腳本語(yǔ)言、公共網(wǎng)關(guān)接口、組件等),可以創(chuàng)造出功能強(qiáng)大的網(wǎng)頁(yè)。因而,超級(jí)文本標(biāo)記語(yǔ)言是萬(wàn)維網(wǎng)(Web)編程的基礎(chǔ),也就是說(shuō)萬(wàn)維網(wǎng)是建立在超文本基礎(chǔ)之上的。超級(jí)文本標(biāo)記語(yǔ)言之所以稱為超文本標(biāo)記語(yǔ)言,是因?yàn)槲谋局邪怂^“超級(jí)鏈接”點(diǎn)。 本篇文章給大家?guī)?lái)的內(nèi)容是關(guān)于php文件中xml格式的使用實(shí)例,有一定的參考價(jià)值,有需要的朋友可以參考一下,希望對(duì)你有所幫助。在寫(xiě)一個(gè)調(diào)查問(wèn)卷的過(guò)程中用到了xml文件,如想要了解,可以通過(guò)以下鏈接簡(jiǎn)單學(xué)習(xí):http://www.php.cn/course/28.html 所用工具:phpstudy+notepad++(使用utf-8編碼無(wú)BOM) 出現(xiàn)的問(wèn)題如下:最開(kāi)始的代碼如下:我想要 求出去長(zhǎng)沙游玩的人數(shù)是多少人,<?php
header('Content-Type: text/xml');
$xmlstr="<?xml version=\"1.0\" encoding=\"utf-8\"?>
<movies>
<movie>
<title>旅游的人數(shù)</title>
<id>1</id>
<count>350</count>
<content>長(zhǎng)沙</content>
</movie>
<movie>
<title>旅游的人數(shù)</title>
<id>2</id>
<count>47</count>
<content>張家界</content>
</movie>
<movie>
<title>旅游的人數(shù)</title>
<id>3</id>
<count>118</count>
<content>上海</content>
</movie>
<movie>
<title>旅游的人數(shù)</title>
<id>4</id>
<count>80</count>
<content>南京</content>
</movie>
</movies>
";
$xml = simplexml_load_string($xmlstr);
$count0 = $xml->movie[0]->count;
echo $count0;
?>火狐瀏覽器上: XML 解析錯(cuò)誤:語(yǔ)法錯(cuò)誤 360瀏覽器上的錯(cuò)誤: This page contains the following errors: error on line 1 at column 1: Document is empty Below is a rendering of the page up to the first error 需要改正的地方是: 去掉第一句:header('Content-Type: text/xml');即可。得到350 2、如果你是需要查看xml格式的時(shí)候 代碼如下: <?php
header('Content-Type: text/xml');
$xmlstr="<?xml version=\"1.0\" encoding=\"utf-8\"?>
<movies>
<movie>
<title>旅游的人數(shù)</title>
<id>1</id>
<count>350</count>
<content>長(zhǎng)沙</content>
</movie>
<movie>
<title>旅游的人數(shù)</title>
<id>2</id>
<count>47</count>
<content>張家界</content>
</movie>
<movie>
<title>旅游的人數(shù)</title>
<id>3</id>
<count>118</count>
<content>上海</content>
</movie>
<movie>
<title>旅游的人數(shù)</title>
<id>4</id>
<count>80</count>
<content>南京</content>
</movie>
</movies>
";就可以得出結(jié)果: This XML file does not appear to have any style information associated with it. The document tree is shown below. <movies> <movie> <title>旅游的人數(shù)</title> <id>1</id> <count>350</count> <content>長(zhǎng)沙</content> </movie> <movie> <title>旅游的人數(shù)</title> <id>2</id> <count>47</count> <content>張家界</content> </movie> <movie> <title>旅游的人數(shù)</title> <id>3</id> <count>118</count> <content>上海</content> </movie> <movie> <title>旅游的人數(shù)</title> <id>4</id> <count>80</count> <content>南京</content> </movie> </movies> "; 上方的那句話可以不用管:在IE瀏覽器上沒(méi)有那句話 所以只是因?yàn)槠渌麨g覽器的兼容性而已。 以上就是php文件中xml格式的使用實(shí)例的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注php中文網(wǎng)其它相關(guān)文章! 網(wǎng)站建設(shè)是一個(gè)廣義的術(shù)語(yǔ),涵蓋了許多不同的技能和學(xué)科中所使用的生產(chǎn)和維護(hù)的網(wǎng)站。 |
溫馨提示:喜歡本站的話,請(qǐng)收藏一下本站!