PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Gonzalo Chumillas   PHP CSS Parser   README.md   Download  
File: README.md
Role: Documentation
Content type: text/plain
Description: Documentation
Class: PHP CSS Parser
Get HTML document nodes matching a CSS selector
Author: By
Last change:
Date: 10 years ago
Size: 2,022 bytes
 

Contents

Class file image Download
# cssparser Evaluates a CSS selector expression and filters nodes from a given DOMNode object. For example: ```php // loads an xml document $doc = new DOMDocument("1.0", "UTF-8"); $doc->load('test.xml'); // filters nodes $p = new CSSParser($doc, 'books item.sci-fi.horror[author_id ^= theodore][author_id $= sturgeon]'); $nodes = $p->parse(); // prints nodes foreach ($nodes as $node) { echo CSSHelper::dom2str($node) . "\n~~~\n"; } ``` ### Supported features #### Basic selectors: 1. [All Selector (“*”)](http://api.jquery.com/all-selector/) 2. [Class Selector (“.class”)](http://api.jquery.com/class-selector/) 3. [Element Selector (“element”)](http://api.jquery.com/element-selector/) 4. [ID Selector (“#id”)](http://api.jquery.com/id-selector/) 5. [Multiple Selector (“selector1, selector2, selectorN”)](http://api.jquery.com/multiple-selector/) #### Child filters: 1. [:first-child Selector](http://api.jquery.com/first-child-selector/) 2. [:nth-child() Selector](http://api.jquery.com/nth-child-selector/) #### Attribute filters: 1. [Attribute Contains Prefix Selector \[name|="value"\]](http://api.jquery.com/attribute-contains-prefix-selector/) 2. [Attribute Contains Selector \[name*="value"\]](http://api.jquery.com/attribute-contains-selector/) 3. [Attribute Contains Word Selector \[name~="value"\]](http://api.jquery.com/attribute-contains-word-selector/) 4. [Attribute Ends With Selector \[name$="value"\]](http://api.jquery.com/attribute-ends-with-selector/) 5. [Attribute Equals Selector \[name="value"\]](http://api.jquery.com/attribute-equals-selector/) 6. [Attribute Not Equal Selector \[name!="value"\]](http://api.jquery.com/attribute-not-equal-selector/) 7. [Attribute Starts With Selector \[name^="value"\]](http://api.jquery.com/attribute-starts-with-selector/) 8. [Has Attribute Selector \[name\]](http://api.jquery.com/has-attribute-selector/) 9. [Multiple Attribute Selector \[name="value"\]\[name2="value2"\]](http://api.jquery.com/multiple-attribute-selector/)