0

I have managed to drill down to the element that I want. Here is an example of the html markup

<p> <strong> Title foo </strong> foo bar foo bar </p>

Is there a way to check if the string of a node contains <strong> or <b> etc? Is there a way to do this with DOMDocument or would I have to implement an xpath solution??

Thanks.

2 Answers 2

1

Is there a way to check if the string of a node contains or etc

Try looking at the textContent property of the node. Watch out, textContent searches both the node and all descendants. If you need a precise match and don't want to crawl the tree yourself, then a xpath solution would probably be faster.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use a regular expression to check whether the string you are looking for is included in the content of the node.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.