Jump to content

[SOLVED] HTML Parsing


rarebit

Recommended Posts

If it's strict XML or XHTML, you can use any of the PHP XML Parsing packages. SimpleXML is by far the easiest. If it's just HTML from some page, in which you can't guarantee it's well formed, you will have to use regular expressions to strip out the data you want.

Link to comment
Share on other sites

Basically into some form of array so it can be studied for seo quality...

 

DOMDocument, Tidy and a few others don't seem to be installed on my server, so i'm currently having a look at XML Parser and simpleXML, but have also grabbed a few preg_split concoctions.

 

Any suggestions?

Link to comment
Share on other sites

How do you parse a definitely html page using SimpleXML, I keep getting errors...

 

$fn = "../test_pages/lq/index.html";
$s = file_get_contents($fn);

$dom = null;
try {
$dom = @new SimpleXMLElement($s);
} catch (Exception $e) {
echo "error";
}
print_r($dom);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.