DOM Interoperation
One nice feature of the XMLReader extension is the expand() method, which returns an object of the equivalent DOM extension class for the node to which the iterator currently points. Element nodes, for example, cause this method to return a DOMElement instance. The example below illustrates a modification to the previous example and provides another alternative to the readString() method for getting at the contents of table cells by taking advantage of this DOM interoperability. <?php if ($doc->localName == 'td' && $inTable) { $node = $doc->expand(); $tableData[$row][] = $node->nodeValue; } ?> © XMLReader Extension — Web Scraping >>> Back to TABLE OF CONTENTS <<< | |
Views: 331 | |
Total comments: 0 | |