I'm writing a script that takes a webpage and detects how many times stuff like a facebook like button is used. Since this would best be done with a DOM, I decided to use PHP's DOMDocument.
The one problem I have come across, though, is for elements like facebook's like button:
<fb:like send="true" width="450" show_faces="true"></fb:like>
Since this element technically has a namespace of "fb", DOMDocument throws a warning saying this namespace prefix is not defined. It then proceeds to strip off the prefix, so when I get to said element, its tag is no longer fb:like, but instead, like.
Is there any way to "pre-register" a namespace? Any suggestions?
You could use tidy to spruce things up before using an xml parser on it.
$tidy = new tidy();
$config = array(
'output-xml' => true,
'input-xml' => true,
'add-xml-decl' => true,
);
$tidy->ParseString($htmlSoup, $config);
$tidy->cleanRepair();
echo $tidy;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With