Tag: php

Extract multiple lines of HTML using Regular Expression in PHP

Extract HTML content using regular expression (regex) involving multiple line of data cannot be done without additional PRCE pattern modifier sU. The dot-asterisk (.*) alone will not allow PHP regex function to perform accordingly as the dot repesents all characters except newline. Bummer.

Appending DOMNode from DOMXPath back to DOMDocument

DOMXPath is a very simple and good way of traversing HTML and search for a particular node. Playing around with its query function provide straight forward method in retrieving each node’s name and value.