PHP DOMDocument对象具有null documentElement,用于有效的XML

The XML I'm working with is actually the RSS feed located at http://www.gjc.org/cgi-bin/rssjobs.pl

It seems to validate via the W3C RSS Feed and XML validators. When I do the following, I just get null.

$dom = new DOMDocument($xml);
$dom->loadXML($xml);
var_dump($dom->documentElement);

Am I missing something obvious? Maybe an encoding problem? Any insight would be appreciated.

You need to convert the encoding to make it work, try the following:

$xml = file_get_contents("http://www.gjc.org/cgi-bin/rssjobs.pl");
$xml = mb_convert_encoding($xml, 'HTML-ENTITIES', "UTF-8");

$dom = new DOMDocument($xml);
$dom->loadXML($xml);
var_dump($dom->documentElement);

This will convert the characters accordingly.