ya pili izi loadHTML($html); } /*** discard white space - TopicsExpress



          

ya pili izi loadHTML($html); } /*** discard white space ***/ $dom->preserveWhiteSpace = false; /*** the tag by its tag name ***/ $content = $dom->getElementsByTagname($tag); /*** the array to return ***/ $out = array(); foreach ($content as $item) { /*** add node value to the out array ***/ $out[] = $item->nodeValue; } /*** return the results ***/ return $out; } ?> In this example plain HTML is used and no third arguement is supplied to the function. This allows for invalid, or broken HTML. The third paragraph is missing a closing tag, however, with the use of DOM and the loadHTML this deviation is allowed. The example will still parse the HTML and retrieve an array of all the text between all anchor tags. In this final example two custom tags are used such as may be found in XML or XHTML documents. The third parameter is set to one which tells the function to use XML mode and parse the custom tags.
Posted on: Thu, 05 Sep 2013 15:04:49 +0000

Trending Topics



Recently Viewed Topics




© 2015