jQuery-like interface for PHP?

前端 未结 12 1694
猫巷女王i
猫巷女王i 2020-12-04 13:44

I was curious as to whether or not there exists a jQuery-style interface/library for PHP for handling HTML/XML files -- specifically using jQuery style selectors.

I\

相关标签:
12条回答
  • 2020-12-04 13:48

    simplexml perhaps? Its syntax is different from jquery, but it does make traversing XML really easy.

    It will however not work for HTML that is not valid XML.

    0 讨论(0)
  • 2020-12-04 13:50

    http://fluentdom.org/ is another alternative.

    0 讨论(0)
  • 2020-12-04 13:53

    my alternative is https://github.com/gymadarasz/xparser

    fast and easy to use, an example:

    $x('#nav a', function($elem) {
      $elem->href = '//myurl/' . $elem->href;
    });
    
    0 讨论(0)
  • 2020-12-04 13:57

    HtmlPageDom extends Symfony's DOM Crawler and adds jQuery-like DOM manipulation functions.

    0 讨论(0)
  • 2020-12-04 14:00

    Doing some more hunting, I think I might've found precisely what I was looking for:

    phpQuery - jQuery port to PHP

    Thanks everyone for your answers, I will definitely keep them in mind for other uses.

    0 讨论(0)
  • 2020-12-04 14:01

    The best one I found is https://github.com/scotteh/php-dom-wrapper

    It works very similarly as jQuery, and it is fast.

    I tried many libraries from other answers, but I didn't manage to port the manipulations I was doing in jQuery easily. With this one it was a breeze. I guess it will become more popular soon...

    0 讨论(0)
提交回复
热议问题