1

I am useing Zend\Dom\Query to get specific content from a webpage.

This is the html:

<div class="menuName darkGreen leftMenu">
   <a href="index.php?ref=MjBfMDJfMDZfMTRfMV8x">Mouse</a>
</div>

How can I get the value Mouse ??

Thanks

2 Answers 2

2

Try this:

$dom = new \Zend\Dom\Query($html);
$results = $dom->execute('div.menuName a');
$doc = $results->current();
var_dump($doc->nodeValue);
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for reply. It is working. I would like to know more about this current() function. I need the documentation. I have another problem like below <br/> <div class="logo_left"> <a href="http://www.abc.com"> <img alt="abc" data-cfsrc="abc" src="**http://www.abc.com/logo.jpg**"> </a> </div> <br/> I would like to catch img src attribute. <br/> Thanks
1

Try this:

$doc->getAttribute('src');

Comments

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.