这个你应该是你的Wamp配置上问题,你看看?
我这边跑起来是没有问题的。
<?php
$url = "https://www.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=cancer";
$file_in = simplexml_load_file($url);
/home/ubuntu/workspace/demo.php:4: class SimpleXMLElement#1 (7) { public $Count => string(7) "3421181" public $RetMax => string(2) "20" public $RetStart => string(1) "0" public $IdList => class SimpleXMLElement#2 (1) { public $Id => array(20) { [0] => string(8) "28092924" [1] => string(8) "28092900" [2] => string(8) "28092882" [3] => string(8) "28092855" [4] => string(8) "28092843" [5] => string(8) "28092842" [6] => string(8) "28092839" [7] => string(8) "28092836" [8] => string(8) "28092835" [9] => string(8) "28092826" [10] => string(8) "28092823" [11] => string(8) "28092822" [12] => string(8) "28092816" [13] => string(8) "28092804" [14] => string(8) "28092803" [15] => string(8) "28092802" [16] => string(8) "28092786" [17] => string(8) "28092770" [18] => string(8) "28092746" [19] => string(8) "28092744" } } public $TranslationSet => class SimpleXMLElement#3 (1) { public $Translation => class SimpleXMLElement#5 (2) { public $From => string(6) "cancer" public $To => string(74) ""neoplasms"[MeSH Terms] OR "neoplasms"[All Fields] OR "cancer"[All Fields]" } } public $TranslationStack => class SimpleXMLElement#4 (2) { public $TermSet => array(3) { [0] => class SimpleXMLElement#5 (4) { ... } [1] => class SimpleXMLElement#6 (4) { ... } [2] => class SimpleXMLElement#7 (4) { ... } } public $OP => array(3) { [0] => string(2) "OR" [1] => string(2) "OR" [2] => string(5) "GROUP" } } public $QueryTranslation => string(74) ""neoplasms"[MeSH Terms] OR "neoplasms"[All Fields] OR "cancer"[All Fields]" }
<?php
$doc = new DOMDocument();
$url = "https://www.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=cancer";
$doc->load($url);
$bookDom = $doc->getElementsByTagName("IdList");
echo "
";
foreach($bookDom as $IdList)
{
$PMID = $IdList->getElementsByTagName("Id")->item(1)->nodeValue;
}
echo "title: " . $PMID . "
";title: 28092900