$doc=new DOMDocument(); 
 $doc->loadHTML($str);  
 $doc->getElementById("MainTable")->getAttribute("id");

Displays the error

Fatal error: Call to a member function getAttribute() on a non-object

Oh and $str is the HTML of a page :p

D: Am I doing something wrong? :o

Recommended Answers

Didn't get your logic.
You are searching from id and want id of searched field ??

Jump to Post

All 3 Replies

Didn't get your logic.
You are searching from id and want id of searched field ??

Didn't get your logic.
You are searching from id and want id of searched field ??

-facepalm-
I was isolating parts from the rest of the code to see which part wasn't working. And in order for it to actually do something, I just put that there.

LOL XD I found the problem :3 The page I was grabbing (to view its source code) was redirecting to something else :p

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.