http://www.cryosphere.f2s.com/Freelancer/example.html
(thats just a demo my actual page has nearly 900 entries)
and put all that data into a database, im just at the beginning and already having trouble, and cannot figure out what
first im trying to parse the html file to grab the info i want, using loadHTMLFile() I created the following script from the example
test.php
Code: Select all
<?php
$doc = new DOMDocument();
$doc->loadHTML("ex2.html");
$tags = $doc->getElementsByTagName('a');
foreach ($tags as $tag) {
echo $tag->getAttribute('href').' | '.$tag->nodeValue."\n";
}
?>ex2.html
Code: Select all
<html>
<head>
<title>My Page</title>
</head>
<body>
<p><a href="/mypage1">Hello World!</a></p>
<p><a href="/mypage2">Another Hello World!</a></p>
</body>
</html>the origional example of
Code: Select all
<?php
$myhtml = <<<EOF
<html>
<head>
<title>My Page</title>
</head>
<body>
<p><a href="/mypage1">Hello World!</a></p>
<p><a href="/mypage2">Another Hello World!</a></p>
</body>
</html>
EOF;
$doc = new DOMDocument();
$doc->loadHTML($myhtml);
$tags = $doc->getElementsByTagName('a');
foreach ($tags as $tag) {
echo $tag->getAttribute('href').' | '.$tag->nodeValue."\n";
}
?>