Php Xml解析之DOMDocument使用方法浅解
用到的XML文件还以“Php Xml处理之simplexml使用方法浅谈”一文中的XML为例,文件名为:me.xml。代码如下:
PHP XML处理XML代码
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
phplamp
>
<
post
>
<
title
id
=
"1"
>
PHP XML处理介绍一
</
title
>
<
details
>
详细内容一
</
details
>
</
post
>
<
post
>
<
title
id
=
"2"
>
PHP XML处理介绍二
</
title
>
<
details
>
详细内容二
</
details
>
</
post
>
<
post
>
<
title
id
=
"3"
>
PHP XML处理介绍三
</
title
>
<
details
>
详细内容三
</
details
>
</
post
>
</
phplamp
>
然后就需要用PHP的DOMDocument去处理这个文件,将XML文件中的任何元素都解析出来。代码如下,里面有注释。
PHP Xml解析DOMDocument代码
<?php
// 首先要建一个DOMDocument对象
$xml
=
new
DOMDocument();
// 加载Xml文件
$xml
->load(
"me.xml"
);
// 获取所有的post标签
$postDom
=
$xml
->getElementsByTagName(
"post"
);
// 循环遍历post标签
foreach
(
$po
相关文档:
摘要 本文介绍PHP的优点和特征,结合实例阐述了PHP访问MySQL数据库的方法。
PHP MySQL ODBC
1. 引言
在Internet应用中,将服务器端脚本技术和客户端脚本技术结合起来可以制作出丰富多彩的页面。CGI和ASP是比较流行的服务器端脚本技术。通常CGI在跨平台的开发中扮演着主要角色,可以使用VB、C或P ......
一、安装系统环境
1、系统:centos5
2、测试在vm5.5
准备软件
lighttpd-1.4.18
下载地址
mysql-5.0.41
part1下载地址
part2下载地址
part3下载地址
php-5.2.3
下载地址
SupeSite/X-Space
part1下载地址
part2下载地址
part3下载地址
discuz
下载地址
二、搭建web服务器安装过程
1、mysql5安装
$ tar zx ......
//创建文件夹的方法
//$path 为文件夹参数,如 (c:/program files/makedir)
function createFolders($path) {
if (!file_exists($path)) {
$this->createFolders(dirname($path));
mkdir($path, 0777);
&n ......
PHP Security for Deployers
If you're a Developer
READ THIS and then work with your SysAdmins to step through any and all the layers of security designed to protect your apps.
Example:
Traffic must first pass through a SPI firewall (ensure that ONLY necessary ports/protocols are permitted; en ......