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

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>


相关文档:

10段PHP常用功能代码

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 ......

2010年最新PHP类的精缩归纳

一:结构和调用(实例化):
class className{} ,调用:$obj = new className();当类有构造函数时,还应传入参数。如$obj = new className($v,$v2...);
二:构造函数和析构函数:
1、构造函数用于初始化:使用__construct(),可带参数。
2、但析构函数不能带参数(用于在销去一个类之前执行一些操作或功能)。析构函数用 ......

PHP MVC 初探

闲来有空,学习一下PHP的MVC模式,充实一下自我,不至于落后。看了个简单的示例
,做点记录。
单点入口:
1. 所有程序都是通过index.php来进行调用的,这要靠.htaccess文件来进行控制。
2. URL router可以由单独的Router类来进行Controller的选择,也可以放在index.php中进行选择。
3. Config最好放到单独的文件中,结 ......

Linux下Apache2+MySQL5+PHP5安装

安装环境:VMware Workstation 5.5.0 build-18463
Linux版本:Red Hat Enterprise Linux AS (2.6.9-42.EL)
软件版本:MySQL5 - mysql-5.0.37.tar.gz
     Apache2 - httpd-2.2.4.tar.gz
     PHP5 - php-5.2.1.tar.gz
     (将以上文件保存至/home/tmp目录)
[MySQL]
# cd /home/tmp (进入压缩包 ......

实现支持post和get的PHP函数

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"] ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号