Is there a JQuery DOM manipulator/CSS selector equivalent class in PHP?

陌路散爱 提交于 2019-12-04 17:13:57

Well, excluding all the JavaScript specific stuff you're left with a CSS selector engine:

http://framework.zend.com/manual/en/zend.dom.query.html

Enjoy :)

You can use phpQuery

It describes itself as follows: phpQuery is a PHP5 server-side, chainable, CSS3 selector driven Document Object Model (DOM) API based on the jQuery JavaScript Library.

Yes, HtmlPageDom is written exactly for what you are asking.

@retro: what he is asking for is a library like sizzle which works using PHP as a language instead of javascript, what you said about "no change to write it" is wrong, it's just code, you can write it as much as you want.

however, the problem I believe is that javascript running inside a browser gives you a +1 up on having access to a DOM system which can help you a lot in creating a lot of dom nodes / html nodes automatically without having to do them yourself.

in php, the DOM is just painful, jquery happily hides this away and as javascript works differently than PHP, it can do that without much effort, however PHP not having access to the browser DOM and having a different method of operation, it's much more painful.

thats not to say it's impossible, because it is, it's just that it's not as easy and sometimes it's different when there doesn't seem to be a clear reason why, I believe it might be that the PHP DOM internally uses libXML or something similar and exposes far too much of that library internally so PHP gets cluttered up with the C library semantics.

I think you should look at phpQuery(https://github.com/TobiaszCudnik/phpquery), or even better and in active development, QueryPath (http://querypath.org).

however, don't expect them to be as easy as the javascript jquery library, cause it's not, unfortunately.....

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!