dil_bert Posted November 18, 2019 Share Posted November 18, 2019 hello dear community, good day, 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". And now - with this i need help. 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 unfortunatley this ends up in a bad result; i need a helping hand and need to know how to parse the above mentioned data Again; the goal: i need the following data: Quote Version: Last updated: Active installations: Tested up: Any idea for the starting-point!? I love to hear from you. Quote Link to comment https://forums.phpfreaks.com/topic/309543-php-dom-document-and-xpath-fetch-class-data/ Share on other sites More sharing options...
requinix Posted November 18, 2019 Share Posted November 18, 2019 I ignored everything in your post after the first few lines because it looked like unnecessary background information irrelevant to the question. $node is an object. You cannot simply echo it. Do something else. Quote Link to comment https://forums.phpfreaks.com/topic/309543-php-dom-document-and-xpath-fetch-class-data/#findComment-1571676 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.