深入研究 DOMElement
我已经使用 Zend_Dom_Query 提取了一些 元素,现在我想循环遍历它们并执行更多操作。每个
看起来像这样,那么如何打印标题
Title 1
和第二个td的idid=categ-113
?
<tr class="sometr">
<th><a class="title">Title1</a></th>
<td class="category" id="categ-113"></td>
<td class="somename">Title 1 name</td>
</tr>
I've used Zend_Dom_Query to extract some <tr>
elements and I want to now loop through them and do some more. Each <tr>
looks like this, so how can I print the title Title 1
and the id of the second td id=categ-113
?
<tr class="sometr">
<th><a class="title">Title1</a></th>
<td class="category" id="categ-113"></td>
<td class="somename">Title 1 name</td>
</tr>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你应该只是玩弄结果。我从来没有使用过它,但这就是我所取得的进展(我自己对 Zend 还很陌生):
有了这个,我想你就可以开始了。有关结果的更多信息和要使用的函数,请查找 DOMElement ( http://php. net/manual/de/class.domelement.php )。有了这些信息,您应该能够掌握所有这些信息。但我的问题是:
为什么这样做如此复杂,我真的没有看到这样做的用例。由于标题和其他所有内容都应该来自数据库?如果它是 XML,则有比依赖 Dom_Query 更好的解决方案。
无论如何,如果这对您有帮助,请接受和/或投票答案。
You should just play around with the results. I've never worked with it, but this is how far i got (and im kinda new to Zend myself):
And with this i think you're set to go. For further information and functions to be used of the result look up DOMElement ( http://php.net/manual/de/class.domelement.php ). With this information you should be able to grab all that. But my question is:
Why doing this so complicated, i don't really see a use-case for doing this. As the title and everything else should be something coming from the database? And if it's an XML there's better solutions than relying on Dom_Query.
Anyways, if this was helpful to you please accept and/or vote the answer.