PHP Classes


Recommend this page to a friend!
  Classes of Gonzalo Chumillas   PHP CSS Parser   Download  
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


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 (“*”)]( 2. [Class Selector (“.class”)]( 3. [Element Selector (“element”)]( 4. [ID Selector (“#id”)]( 5. [Multiple Selector (“selector1, selector2, selectorN”)]( #### Child filters: 1. [:first-child Selector]( 2. [:nth-child() Selector]( #### Attribute filters: 1. [Attribute Contains Prefix Selector \[name|="value"\]]( 2. [Attribute Contains Selector \[name*="value"\]]( 3. [Attribute Contains Word Selector \[name~="value"\]]( 4. [Attribute Ends With Selector \[name$="value"\]]( 5. [Attribute Equals Selector \[name="value"\]]( 6. [Attribute Not Equal Selector \[name!="value"\]]( 7. [Attribute Starts With Selector \[name^="value"\]]( 8. [Has Attribute Selector \[name\]]( 9. [Multiple Attribute Selector \[name="value"\]\[name2="value2"\]](