使用simplexml解析特殊字符xml文件

Apologies if there is an obvious answer (and I know there are about 1000 of these similar questions) - but I have spent two days trying to attack this without success. I cannot seem to crack why I get a null response...

Short background: the following works just fine

$xurl= new SimpleXMLElement('https://gptxsw.appspot.com/view/submissionList?formId=GP_v7&numEntries=1', NULL,    TRUE);
$keyname = $xurl->idList->id[0];
echo $keyname;

this provides a response: a unique key like uuid:d0721391-6953-4d0b-b981-26e38f05d2e5

however I try a similar request (which ultimately would be based on first request) and get a failure. I've simplified code as follows...

$xdurl= new SimpleXMLElement('https://gptxsw.appspot.com/view/downloadSubmission?formId=GP_v7[@version=null%20and%20@uiVersion=null]/GP_v7[@key=uuid:d0721391-6953-4d0b-b981-26e38f05d2e5]', NULL, TRUE);
$keyname2 = $xdurl->data->GP_v7->SDD_ID_N[0];
echo $keyname2;

this provides null. And if I try something like echo $xdurl->asXML(); I get an error response from the site (not from PHP).

Do I need to eject from SimpleXMLElement for the second request? I've read about using XPath and about defining the namespace, but I'm not sure that either would be required: the second file does have two namespaces but one of them isn't used and the other has no prefix for elements. Plus I have tried variations of those - enough to think that my problem/error is either more global in nature (or oversight due to inexperience).

For purposes of this request I have no control over the formatting of either XML file.

Thanks to @Matze for getting me on right track. Issue is that URL has special characters that SimpleXMLElement cannot parse without help.

Solution: add urlencode() command like the following

$fixurl = urlencode('https://gptxsw.appspot.com/view/downloadSubmission?formId=GP_v7[@version=null and     @uiVersion=null]/GP_v7[@key=uuid:d0721391-6953-4d0b-b981-26e38f05d2e5]');
$xdurl= new SimpleXMLElement($fixurl, NULL, TRUE);
$keyname2 = $xdurl->data->GP_v7->SDD_ID_N[0];
echo $keyname2;

this provided the answer (in this case 958)

Here we go: SimpleXMLElement seems to re-escape (or incorrectly handle in some way) already url-escaped characters like white spaces. Try:

$xdurl= new SimpleXMLElement('https://gptxsw.appspot.com/view/downloadSubmission?formId=GP_v7[@version=null and @uiVersion=null]/GP_v7[@key=uuid:d0721391-6953-4d0b-b981-26e38f05d2e5]', NULL, TRUE);
$keyname2 = $xdurl->data->GP_v7->SDD_ID_N[0];
echo $keyname2;

and you should be fine.

(FYI: I debugged this by manually creating a local copy of the XML request result named "foo.xml" which worked perfectly.)