PhpQuery PHP操作HTML类,PHP操作XML类,PHP操作Dom类
来源:互联网 发布:环保监测数据 编辑:程序博客网 时间:2024/06/05 14:40
PHP操作HTML类,PHP操作XML类,PHP操作Dom类
PHP操作Dom类,PHP操作XML类,,PHP操作HTML类
一个不错的类 PhpQuery
PhpQuery用法
require('phpQuery/phpQuery.php');
// INITIALIZE IT
// phpQuery::newDocumentHTML($markup);
// phpQuery::newDocumentXML();
// phpQuery::newDocumentFileXHTML('test.html');
// phpQuery::newDocumentFilePHP('test.php');
// phpQuery::newDocument('test.xml', 'application/rss+xml');
// this one defaults to text/html in utf8
$doc = phpQuery::newDocument('<div/>');
// FILL IT
// array syntax works like ->find() here
$doc['div']->append('<ul></ul>');
// array set changes inner html
$doc['div ul']='<li>1</li> <li>2</li> <li>3</li>';
// MANIPULATE IT
$li =null;
// almost everything can be a chain
$doc['ul > li']
->addClass('my-new-class')
->filter(':last')
->addClass('last-li')
// save it anywhere in the chain
->toReference($li);
// SELECT DOCUMENT
// pq(); is using selected document as default
phpQuery::selectDocument($doc);
// documents are selected when created or by above method
// query all unordered lists in last selected document
$ul = pq('ul')->insertAfter('div');
// ITERATE IT
// all direct LIs from $ul
foreach($ul['> li']as $li){
// iteration returns PLAIN dom nodes, NOT phpQuery objects
$tagName = $li->tagName;
$childNodes = $li->childNodes;
// so you NEED to wrap it within phpQuery, using pq();
pq($li)->addClass('my-second-new-class');
}
// PRINT OUTPUT
// 1st way
print phpQuery::getDocument($doc->getDocumentID());
// 2nd way
print phpQuery::getDocument(pq('div')->getDocumentID());
// 3rd way
print pq('div')->getDocument();
// 4th way
print $doc->htmlOuter();
// 5th way
print $doc;
// another...
print $doc['ul'];
下载地址:http://code.google.com/p/phpquery/
- PhpQuery PHP操作HTML类,PHP操作XML类,PHP操作Dom类
- PHP通过DOM操作XML
- PHP通过DOM操作XML
- PHP通过DOM操作XML
- PHP XML操作类DOMDocument
- php封装xml操作类
- PHP XML操作类DOMDocument
- PHP的xml操作类
- PHP XML Library:一个不错的PHP XML操作类
- php dom操作
- PHP DOM操作
- php操作dom节点
- PHP中DOM操作
- php操作html元素,使用PHP Simple HTML DOM Parser
- php dom操作存储xml节点
- PHP原生DOM对象操作XML
- Php原生DOM对象如何操作XML
- PHP操作XML做数据库的类
- 判断手机号码,电话号码函数
- D3DPRESENT_PARAMETERS参数
- 贴一份宏定义 防止丢失
- C++语言复习八 结构体指针(指向类的指针)的两种引用方式。
- 关于PHP你可能不知道的-PHP的事件驱动化设计
- PhpQuery PHP操作HTML类,PHP操作XML类,PHP操作Dom类
- API总结3
- NoSQL入门文章推荐
- DTree
- Eclipse中Struts2的必须包
- libeio源码分析 – 主流程
- 函数指针传递的两种环境(全局函数与类成员函数)
- 自我保护第一课加密与防破解
- 怎么用Java生成客户端调用接口