这是这个问题的后续问题。
同样的想法:我从 PubMed 提取数据作为 XML 并使用 curl 来处理这些结果。这使我能够获取我需要的信息(pub ID 列表)并将其用作另一个 PubMed 抓取的变量。$name 最终将是动态的。
<?php
$name = 'white,theodore';
// Return xml data from PubMed based on author search name
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term='.$name.'[author]&retmode=xml&retmax=50');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
$output = curl_exec($ch);
curl_close($ch);
// Parse the results and concatenate into a string of Publication IDs
$xml=simplexml_load_string($output);
$idList = $xml->IdList;
$ids = "";
foreach($idList->children() as $id) {
$ids .= $id . ",";
}
// Plug that string of IDs into another PubMed search, this one returning XML data for Publication Summaries
$path = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=pubmed&id='.$ids;
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, $path);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch2, CURLOPT_VERBOSE, 0);
curl_setopt($ch2, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch2, CURLOPT_AUTOREFERER, true);
curl_setopt($ch2, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch2, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch2, CURLOPT_FRESH_CONNECT, 1);
$data = curl_exec($ch2);
curl_close($ch2);
// Parse those results and print only what is needed for Citation format
$cxml=simplexml_load_string($data);
foreach($cxml->children() as $docsum) {
foreach($docsum->children() as $item) {
foreach($item->children() as $details) {
if ((string) $details['Name'] === 'Author') {echo $details . "., ";}
}
if ((string) $item['Name'] === 'FullJournalName') { echo $item . ". "; }
if ((string) $item['Name'] === 'Title') { echo "<strong>" . $item . "</strong> "; }
if ((string) $item['Name'] === 'Volume') { echo "Vol." . $item . ", "; }
if ((string) $item['Name'] === 'Issue') { echo "Issue" . $item . ". "; }
if ((string) $item['Name'] === 'PubDate') { echo $item . ". "; }
foreach($item->children() as $details) {
if ((string) $details['Name'] === 'PubType') {echo $details . ", ";}
}
}
echo "</br></br>";
}
?>
它返回以下 XML 数据(这是一个结果)。
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE eSummaryResult PUBLIC "-//NLM//DTD esummary v1 20041029//EN" "https://eutils.ncbi.nlm.nih.gov/eutils/dtd/20041029/esummary-v1.dtd">
<eSummaryResult>
<DocSum>
<Id>27431223</Id>
<Item Name="PubDate" Type="Date">2016 Oct</Item>
<Item Name="EPubDate" Type="Date">2016 Sep 23</Item>
<Item Name="Source" Type="String">Antimicrob Agents Chemother</Item>
<Item Name="AuthorList" Type="List">
<Item Name="Author" Type="String">Bhattacharya S</Item>
<Item Name="Author" Type="String">Sobel JD</Item>
<Item Name="Author" Type="String">White TC</Item>
</Item>
<Item Name="LastAuthor" Type="String">White TC</Item>
<Item Name="Title" Type="String">A Combination Fluorescence Assay Demonstrates Increased Efflux Pump Activity as a Resistance Mechanism in Azole-Resistant Vaginal Candida albicans Isolates.</Item>
<Item Name="Volume" Type="String">60</Item>
<Item Name="Issue" Type="String">10</Item>
<Item Name="Pages" Type="String">5858-66</Item>
<Item Name="LangList" Type="List">
<Item Name="Lang" Type="String">English</Item>
</Item>
<Item Name="NlmUniqueID" Type="String">0315061</Item>
<Item Name="ISSN" Type="String">0066-4804</Item>
<Item Name="ESSN" Type="String">1098-6596</Item>
<Item Name="PubTypeList" Type="List">
<Item Name="PubType" Type="String">Journal Article</Item>
</Item>
<Item Name="RecordStatus" Type="String">Unknown status</Item>
<Item Name="PubStatus" Type="String">epublish</Item>
<Item Name="ArticleIds" Type="List">
<Item Name="pubmed" Type="String">27431223</Item>
<Item Name="pii" Type="String">AAC.01252-16</Item>
<Item Name="doi" Type="String">10.1128/AAC.01252-16</Item>
<Item Name="pmc" Type="String">PMC5038269</Item>
<Item Name="rid" Type="String">27431223</Item>
<Item Name="eid" Type="String">27431223</Item>
<Item Name="pmcid" Type="String">pmc-id: PMC5038269;embargo-date: 2017/04/01;</Item>
</Item>
<Item Name="DOI" Type="String">10.1128/AAC.01252-16</Item>
<Item Name="History" Type="List">
<Item Name="received" Type="Date">2016/06/10 00:00</Item>
<Item Name="accepted" Type="Date">2016/07/12 00:00</Item>
<Item Name="pmc-release" Type="Date">2017/04/01 00:00</Item>
<Item Name="entrez" Type="Date">2016/07/20 06:00</Item>
<Item Name="pubmed" Type="Date">2016/07/20 06:00</Item>
<Item Name="medline" Type="Date">2016/07/20 06:00</Item>
</Item>
<Item Name="References" Type="List"></Item>
<Item Name="HasAbstract" Type="Integer">1</Item>
<Item Name="PmcRefCount" Type="Integer">0</Item>
<Item Name="FullJournalName" Type="String">Antimicrobial agents and chemotherapy</Item>
<Item Name="ELocationID" Type="String">doi: 10.1128/AAC.01252-16</Item>
<Item Name="SO" Type="String">2016 Oct;60(10):5858-66</Item>
</DocSum>
</eSummaryResult>
</br></br>
因此呼应:
2016 年 10 月,Bhattacharya S.、Sobel JD.、White TC.,联合荧光分析表明,作为抗唑类阴道白色念珠菌分离株的抗性机制,外排泵活性增加。第 60 卷,第 10 期。期刊文章,抗菌剂和化疗。
Zavrel M.,White TC.,医学上重要的真菌对唑类药物的反应:更新。第 10 卷,第 8 期。期刊文章,评论,未来微生物学。
Esquivel BD.、Smith AR.、Zavrel M.、White TC.、唑类药物导入病原真菌烟曲霉。第 59 卷,第 6 期。期刊文章,抗菌剂和化疗。
2015 年 4 月 Achterman RR.、Moyes DL.、Thavaraj S.、Smith AR.、Blair KM.、White TC.、Naglik JR.,皮肤癣菌通过丝裂原活化蛋白激酶信号传导激活皮肤角质形成细胞并诱导免疫反应。第 83 卷,第 4 期。期刊文章,感染和免疫。
2015 年 2 月 3 日。福特 CB.、Funt JM.、Abbey D.、Issi L.、Guiducci C.、Martinez DA.、Delorey T.、Li BY.、White TC.、Cuomo C.、Rao RP.、Berman J ., Thompson DA., Regev A., 白色念珠菌临床分离株耐药性的演变。第 4 卷,问题。期刊文章,188bet体育电竞。
2014 年 8 月 1 日。White TC.、Findley K.、Dawson TL Jr.、Scheynius A.、Boekhout T.、Cuomo CA.、Xu J.、Saunders CW.、皮肤上的真菌:皮肤癣菌和马拉色菌。第 4 卷,第 8 期。期刊文章,评论,冷泉港医学观点。
2014 年 1 月 Maguire SL.、Wang C.、Holland LM.、Brunel F.、Neuvéglise C.、Nicaud JM.、Zavrel M.、White TC.、Wolfe KH.、Butler G.、锌指转录因子取代了 SREBP 蛋白作为 Saccharomycotina 进化过程中主要的甾醇调节剂。第 10 卷,第 1 期。期刊文章,公共科学图书馆遗传学。
2013 年 11 月 15 日。Campoli P.、Perlin DS.、Kristof AS.、White TC.、Filler SG.、Sheppard DC.、泊沙康唑在上皮细胞和真菌中的药代动力学:深入了解治疗和预防过程中的潜在作用机制。第 208 卷,第 10 期。期刊文章,传染病杂志。
2013 年 7 月 8 日。Achterman RR.,White TC.,皮肤癣菌。第 23 卷,第 13 期。期刊文章,当前生物学:CB。
等等。
一切都很好,并且只使用我需要的数据产生引用但我无法重新排序结果,所以作者排在第一位,PubDate 排在最后,等等。我尝试了很多选项,但我对其中任何一个都不够熟悉,并且似乎无法破解它。
我尝试附加 XSLT 样式表,但我认为这不起作用,因为我实际上并没有输出 XML 文件。也许?
我尝试使用以下 XPath 而不是底部的 SimpleXML 块来返回引文,但始终得到空白结果。因为所有数据都标记为<Item>
,所以我尝试使用 Name 属性没有成功。
$content = simplexml_load_string($data);
$results = $content->xpath('Item[@Name]');
foreach($results as $result) {
$title = $result->xpath('[@Name="Title"]');
// Make sure there's an author attribute
if($title) {
// because we have a list of elements even if there's one result
$items = $title[0]->attributes();
$title = $items['value'];
}
echo $results;
}
我也试过 DOMXPath 和 GetElementsByTagName 无济于事。
基本上,我被困住了。我已经尝试了很多变体并且得到了很多错误,我觉得我在绕圈子飞行。有更多 Xpath 或 XSLT 经验的人有想法吗?