易截截图软件、单文件、免安装、纯绿色、仅160KB

使用SimpleXML函数来加载和解析XML文档

 大量SmipleXML函数可用来加载和解析大量XML文档。
1.simpleXML_load_file()函数来加载指定的XML文件到对象。如果加载文件时遇到问题,则返回FLASE。例:
book.xml文件:
<?xml version="1.0" standalone="yes"?>
<library>
<book>
<title>Pride and Prejudice</title>
<author gender="female">Jane Austen</author>
<description>Jane Austen's most popular work.</description>
</book>
<book>
<title>The Conformist</title>
<author gender="male">Alberto Moravia</author>
<description>Alberto Moravia's classic psyhcological novel.</description>
</book>
<book>
<title>The Sun Also Rises</title>
<author gender="male">Ernest Hemingway</author>
<description>The masterpiece that launched Hemingway's career.</description>
</book>
</library>
php文件:
<?php
/*=====yinyiniao=====*/
$xml=simplexml_load_file("book.xml");echo "<pre>";
var_dump($xml);
?>
输出结果:
 object(SimpleXMLElement)#1 (1) {
["book"]=>
array(3) {
[0]=>
object(SimpleXMLElement)#2 (3) {
["title"]=>
string(19) "Pride and Prejudice"
["author"]=>
string(11) "Jane Austen"
["description"]=>
string(32) "Jane Austen's most popular work."
}
[1]=>
object(SimpleXMLElement)#3 (3) {
["title"]=>
string(14) "The Conformist"
["author"]=>
string(15) "Alberto Moravia"
["description"]=>
string(46) "Alberto Moravia's classic psyhcological novel."
}
[2]=>
object(SimpleXMLElement)#4 (3) {
["title"]=>
string(18) "The Sun Also Rises"
["author"]=>
string(16) "Ernest Hemingway"
["description"]=>
string(49) "The masterpiece that launched Hemingway's career."
}
}
}


相关文档:

Sqlserver:从XML文件中读取配置信息

如何在Sqlserver中从外部XML文件中读取配置信息呢?该问题源自一家企业的笔试信息有感。
一xml文件内容:
<?xml version="1.0" encoding="utf-8"?>
<root>
  <db name="ClientDB1" datasize="512MB" datagrowth="100MB" logsize="100MB" loggrowth ="50MB">
  </db>
  <db ......

xml 声明【注释】 引发的异常


xml -声明-引发的异常
XML 声明 [XML 标准]
XML 声明通常在 XML 文档的第一行出现。XML 声明不是必选项,但是如果使用 XML 声明,必须在文档的第一行,前面不得包含任何其他内容或空白。
文档映射中的 XML 声明包含下列内容:
版本号 <?xml version="1.0"?>。
这是必选项。尽管以后的 XML 版本可能会更改该 ......

用jdom实现将数据库资料生成xml文件

今天的项目模块中用到根据数据库里的资料生成xml文件,主要步骤如下:
(1) 连接数据库,取出数据;
(2) 创建结点,添加子项;
(3) 写入文件“test.xml”中;
具体代码如下:
import java.io.FileOutputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Result ......

XML第二课

wsdl.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<definitions  name="MobilePhoneService"
     targetNamespace="www.mobilephoneservice.com/MobilePhoneService-interface"
     xmlns="http://schemas.xmlsoap.org/wsdl/"
     ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号