Wednesday 15 February 2012

PHP Get File Content -


I am trying to display the contents of a website on the other. I currently have this:

  & lt ;? Php $ file = file_get_contents ('http://linkto.com/the-page'); Copy $ file; ? & Gt;   

It gets everything from that page though, I just have to get a table. I basically just call & lt; Table id = arc & gt; to / Table & gt; All content is required from .

Is there any easy way to edit my code just to get that table? Here's a solution using PHP's local DOM pter:

 

$ doc = new DOMDocument; $ Doc- & gt; Load HTML file ('http://linkto.com/the-page'); // Get the desired table $ table = $ doc- & gt; GetElementById ('Arc'); // Print the HTML of the table $ doc- & gt; Save HTML ($ table);

No comments:

Post a Comment