suppose that a simple html dom object includes the following
text1
<br />
<br />
<br />
text2
<br />
How can i get either of texts using simple html dom?
suppose that a simple html dom object includes the following
text1
<br />
<br />
<br />
text2
<br />
How can i get either of texts using simple html dom?
With jquery try $(document.body).contents();
This should you a array of node with the text1 and text2 as text node.
Just use plaintext to get text value from html.
For class use (
tagname.classname
) and for id use (tagname#id
) to get text.$context is for set header for browser support if any website get mobile version so u can add header to get browser support content.
To grab all plain text elements, you can use the following:
Your output should look something like this:
In the foreach loop, you can obviously do whatever filtering you need to. For instance, if you're trying to find some text that matches a specific string, you can simply do:
So, if you wanted to replace the found text, you could use:
and
$html
will contain the new html.