Home > Backend Development > PHP Tutorial > 这段代码错哪了DOMDOCUMENT

这段代码错哪了DOMDOCUMENT

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:43:54
Original
1019 people have browsed it

这段代码哪里错了DOMDOCUMENT
如果换成previousSibling的话就正常的

<br />$doc = new DOMDocument();<br />$html = <<<HTML<br /><html><br /><body><br /><ul id="list"><br /><li>Foo</li><br /><li>Bar</li><br /></ul><br /><br /><h2 class = 'test'>heading3</h2><br /><br /><h3>heading3</h3><br /><br /><ul id="list2"><br /><li>list2</li><br /><li>list2</li><br /></ul><br /><br /></body><br /></html><br />HTML;<br /><br /><br />$doc ->loadHTML($html);<br /><br />$ul = $doc->getElementsByTagName('*');<br /><br />foreach($ul as $node) {<br />     if ($node -> hasAttribute('class')) {<br /><br />           foreach($node -> nextSibling ->childNodes as $morenodes) {<br /><br />               print_r($morenodes);<br />               }<br />    }<br />  }<br />
Copy after login

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template