php处理xpath
1 <?php
2 $doc = new DOMDocument('1.0', 'utf-8');
3 $doc->load('./articles.xml');
4
5 $xpath = new DOMXPath($doc);
6 /*
7 * $xpath = domxml_open_file("articles.xml");
8 */
9 $arts = $xpath->query("/articles/article/title");
10
11 foreach ($arts as $art)
12 {
13 echo $art->nodeValue." ";
14 }
15 ?>
其中,articles.xml的内容如下:
1 <?xml version="1.0" encoding="UTF-8"?>
2 <articles>
3 <article id="1">
4 <tags>
5 <tag>php</tag>
6 <tag>xpath</tag>
7 </tags>
8 <title>PHP XPath Example</title>
9 </article>
10 <article id="2">
11 <tags>
12 <tag>dom</tag>
13 <tag>dodocument</tag>
14 </tags>
15 <title>DomDocument Tutorial</title>
16 </article>
17 </articles>
相关文档:
1、使用PHP Mail函数发送Email
$to = "viralpatel.net@gmail.com";
$subject = "VIRALPATEL.net";
$body = "Body of your message here you can use HTML too. e.g. ﹤br﹥ ﹤b﹥ Bold ﹤/b﹥";
$headers = "from: Peter\r\n"; &nbs ......
PHP5是一具备了大部分面向对象语言的特性的语言,比PHP4有了很多的面向对象的特性,但是有部分概念也比较难以理解,这里我主要谈的是 this,self,parent三个关键字之间的区别。从字面上比较好理解,分别是指这、自己、父亲。我们先建立几个概念,这三个关键字分别是用在什么 地方呢?我们初步解释一下,this是指向当前对象的指针(姑 ......
< type="text/javascript">
document.body.oncopy = function() {
if (window.clipboardData) {
setTimeout(function() {
var text = clipboardData.getData("text");
......
function getsock($strUrl,$arrParameter=array(),$strMethod="POST"){
if(!$strUrl||!$strMethod){ return "";}
$strMethod = strtoupper($strMethod);
$arrUrl = parse_url($strUrl);
if($arrUrl["port"]==0){$arrUrl["port"]=80;}
$fso = fsockopen($arrUrl["host"],$arrUrl["port"] ......
很多时候我们喜欢用js来获取日期和时间,但这仅仅是客户端的。
我们可以用php的date函数即可来获取服务器上的时间:
<?php
//将时区设置为中国
date_default_timezone_set("PRC");
echo date("Y-m-d l H:i:s A");
//例输出:2010-03-06 Saturday 11:51:29 AM
?> ......