• 0

PHP DOM-Document and XPath : fetch class data


Question

hello dear community,

 

 

I've been having an issue trying to parse text in a span cass with DOM. Here is my code example. try to extract some lines out of a webpage - with following technique: with the Extraction of values of attributes of elements with DOMDocument

Here is what i have gathered and learned:

 

$remote = "http://website.com/"; $doc = new DOMDocument(); @$doc->loadHTMLFile($remote); $xpath = new DOMXpath($doc); $node = $xpath->query('//span[@class="user"]'); echo $node;

 

and this returns the following

 

error -> "Catchable fatal error: Object of class DOMNodeList could not be converted to string". 

 

 

I am so lost..

 

What I am trying to do is parse the user name between this tag;

 

<div class="widget plugin-meta"> <h3 class="screen-reader-text">Meta</h3>

 

see more below:

 

Here the concrete example view-source: https://wordpress.org/plugins/participants-database/ and https://wordpress.org/plugins/participants-database/

 

goal  i need the following data:

 

Version: Last updated: Active installations: Tested up:

 

view-source: https://wordpress.org/plugins/participants-database/

 

Proceedings; i checked the source of the webpage. i tried to find out whether the texte is related to some kind of pattern.i have looked closely and found that all of them have class=”widget plugin-meta”. Well - This will make extracting them, a piece of cake. I tried with the code below helps to filter html elements based on values of attributes.

 

but unfortunatly this ends up in a bad result; i need a helping hand and need to know how to parse the above mentioned data

goal: i need the following data: Version: Last updated: Active installations: Tested up:

 

any ideas!?

 

Edited by tarifa

4 answers to this question

Recommended Posts

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.