php - Catchable fatal error: Object of class DOMNodeList could not be converted to string -


I'm working on my PHP to get the list of URLs. I am using domdocument which for input I have to get the list of URLs and I want to send the request to each url to get the return string.

When I tried to do this:

  if ($ link-> getAttribute ('href')) (if (! $ Link- & gt; ($ Id- Href ')); $ Url = str_replace ("", "% 20", $ link-> getAttribute ('href')); Echo $ url; Echo "& lt; br & gt;"; $ Sdoc = new DOMDocument (); $ Sdoc- & gt; Strict ErrorChecking = false; $ Sdoc- & gt; OK = true @ $ Sdoc- & gt; LoadHTMLFile ($ url); $ Spans = $ sdoc- & gt; GetElementsByTagName ('period'); $ Spans echo; }}  

I will find: Catastrophic Fatal Error: The class dogdomist's object could not be converted to string.

Error is jumping on this line:

resize $ spans;

Here is the list of time strings for each URL that I want to parse:

  & lt; Span id = "time1" & gt; 4: 00 of the Prime Minister & lt; / Span & gt; - & lt; Span id = "time2" & gt; 4: 30 PM & lt; / Span & gt; & Lt; Span id = "time3" & gt; 5: 00 PM  

Here's the code:

   LoadHTML ($ baseurl); // $ links = $ domdoc- & gt; GetElementsByTagName ('test'); // $ links = $ domdoc- & gt; GetElementById ('test'); $ Links = $ domdoc- & gt; GetElementsByTagName ('A'); $ Data = array (); Forex Currency ($ link as $ link) {// resonance $ link- & gt; GetAttribute ('id, test'); // resonance $ test; // echo $ domdoc-> SaveXML ($ link); If ($ link-> getAttribute ('href')) {if (! $ Link- & gt; Detectivity ('id')} $ link-> getAttribute ('id')! = 'Stream' ) {$ Url = str_replace ("rtmp: //", "", $ link-> getAttribute ('href')); $ Url = str_replace ("", "% 20", $ link-> getAttribute ('href')); Echo $ url; Echo "& lt; br & gt;"; $ Sdoc = new DOMDocument (); $ Sdoc- & gt; Strict ErrorChecking = false; $ Sdoc- & gt; OK = true @ $ Sdoc- & gt; LoadHTMLFile ($ url); $ Spans = $ sdoc- & gt; GetElementsByTagName ('period'); $ Query = parse_url ($ url) ['query']; $ Url_split = Explosion ("& amp;", $ query) [0]; $ Channel = urldecode (Explosion ("=", $ url_split) [1]); Forex currency ($ spans as $ spans) {$ id = $ span- & gt; GetAttribute ('time1'); // resonant $ id; }}}}? & Gt;  

Can you please tell me why I have got a catachetly fatal error and how can I resonate the string of times?

It is not clear what values ​​you are trying to achieve, but if its time If you have, you can call node-> gt; NodeValue :

  foreach (spans $ $ spans) {echo $ span- & gt; NodeValue; }  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -