开发者

How to parse HTML correctly with DOMDocument?

开发者 https://www.devze.com 2023-03-31 09:26 出处:网络
Lets say I have this type of HTML website: stuff <div id=\"123\"> *HTML开发者_运维问答 CODE I NEED*

Lets say I have this type of HTML website:

stuff
<div id="123">
*HTML开发者_运维问答 CODE I NEED*
</div>
stuff
<div id="234">
*HTML CODE I NEED*
</div>
more stuff

How can I extract HTML CODE I NEED from those div's, given that I know their IDs ?

Thank you!


You can get the nodes with DOMDocument::getElementById [docs] and the text content with the textContent [docs] property.

If you want the inner HTML of the nodes, you can call DOMDocument::saveHTML [docs].

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号