国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > PHP > 正文

php文件中xml格式的使用實例

2020-03-22 17:54:19
字體:
供稿:網(wǎng)友
本篇文章給大家?guī)淼膬?nèi)容是關(guān)于php文件中xml格式的使用實例,有一定的參考價值,有需要的朋友可以參考一下,希望對你有所幫助。

在寫一個調(diào)查問卷的過程中用到了xml文件,如想要了解,可以通過以下鏈接簡單學習:http://m.survivalescaperooms.com/course/28.html

所用工具:phpstudy+notepad++(使用utf-8編碼無BOM)

出現(xiàn)的問題如下:最開始的代碼如下:我想要 求出去長沙游玩的人數(shù)是多少人,
 ?phpheader( Content-Type: text/xml $xmlstr= ?xml version=/ 1.0/ encoding=/ utf-8/ ?  movies  movie  title 旅游的人數(shù) /title  id 1 /id  count 350 /count  content 長沙 /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 解析錯誤:語法錯誤
位置:http://localhost:8080/diaocha/2.php
行 1,列 1:350

360瀏覽器上的錯誤:

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格式的時候

代碼如下:

 ?phpheader( Content-Type: text/xml $xmlstr= ?xml version=/ 1.0/ encoding=/ utf-8/ ?  movies  movie  title 旅游的人數(shù) /title  id 1 /id  count 350 /count  content 長沙 /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 長沙 /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瀏覽器上沒有那句話 所以只是因為其他瀏覽器的兼容而已。

以上就是php文件中xml格式的使用實例的詳細內(nèi)容,PHP教程

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 浦北县| 婺源县| 禄劝| 平乡县| 忻城县| 宁蒗| 乐亭县| 扎囊县| 巴楚县| 叶城县| 班玛县| 通河县| 大港区| 清涧县| 二手房| 化州市| 祁阳县| 乐都县| 招远市| 景宁| 华安县| 上思县| 云安县| 台东县| 新乡县| 衡阳县| 黄山市| 江西省| 门头沟区| 新余市| 廊坊市| 长寿区| 任丘市| 南岸区| 时尚| 广东省| 华坪县| 房产| 黔南| 长海县| 奉化市|