[eluser]Yorick Peterse[/eluser]
[quote author="nubianxp" date="1241481200"]@yorick: thanks for the code man, nice to have something to start with... one question, is it possible to maybe parse a remote file? e.g.
Code:
$remote = 'http://example.com/data.html';
$DOM = new DOMDocument();
$DOM->load($remote);
$content = $DOM->getElementById('somediv');
and do either
Code:
echo $content; OR
print_r($content);
i tested the above, but i get some parsing errors when using $dom->load():
Code:
Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: error parsing attribute name in http://example.com/forecast.html, line: 19 in E:\localweb\projects\test\getfile.php on line 5
and a blank page if i use $dom->loadHTML()... anyway, appreciate the help. :lol:
@dam1an: 5,344?! and all of those are built-in?! :wow:[/quote]
I'm not really sure if you can parse a remote file using the DOM. However you could use file_get_contents() to fetch whatever is in that file and then parse it later on.
It would look like the following:
Code:
<?php
// Get the content from the remote file
$remote = file_get_contents('your_remote_file.html');
// Load the DOM
$DOM = new DOMDocument();
// Open the $remote variable using the DOM, not sure if it's possible
$DOM->load($remote);
// Parse it
.......