jQuery-like selectors for PHP DOMDocument

前端 未结 5 1444
北荒
北荒 2021-02-01 06:44

I\'m working with a DOMDocument, and I\'m wondering if there exists some way of using CSS-like selectors to select nodes like we would in jQuery.

Example situation: I\'m

5条回答
  •  眼角桃花
    2021-02-01 07:23

    If you want to manipulate the DOM ala Jquery, PHPQuery is something for you.

    http://code.google.com/p/phpquery/

    A simple example of what you can do with it.

    // almost everything can be a chain
    $li = null;
    $doc['ul > li']
            ->addClass('my-new-class')
            ->filter(':last')
                    ->addClass('last-li');
    

提交回复
热议问题