Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse CSS like Simple HTML DOM

Tags:

People also ask

What is simple HTML DOM parser?

The web scraping can be done by targeting the selected DOM components and then processing or storing the text between that DOM element of a web page. To do the same in PHP, there is an API which parses the whole page and looks for the required elements within the DOM. It is the Simple HTML DOM Parser.

What is DOM tree parsing?

The DOMParser interface provides the ability to parse XML or HTML source code from a string into a DOM Document . You can perform the opposite operation—converting a DOM tree into XML or HTML source—using the XMLSerializer interface.

What is parse in HTML?

Parsing means analyzing and converting a program into an internal format that a runtime environment can actually run, for example the JavaScript engine inside browsers. The browser parses HTML into a DOM tree. HTML parsing involves tokenization and tree construction.


So for example I could do like this with it :

$css = new simple_css();
foreach ($css->find_elements_with_property('margin') as $element) {
  //do my stuff
  if ($something) {
    $elem->spacing = '1px';
  }
}
$processed_css = $css->plaintext();