使用php获取网页XML代码并在其上使用XPATH

Maybe its a question answered before but im so noobie in Web Development. Im trying to get a full XML text from this page:

Human Genome

And, I need to do some XPath queries in that code, like "get the ID" and others. For example:

//eSearchResult/IdList/Id/node()

How I can to get the full XML in a php object to request data throught XPath queries?

I used this code before:

<?php
$text = $_REQUEST['text'];
$xmlId = simplexml_load_file('https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=gene&amp;term='.$text.'%5bGene%20Name%5d+AND+%22Homo%20sapiens%22%5bOrganism');
$id = $xmlId->IdList[0]->Id;
$xmlGeneralData = simplexml_load_file('https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=gene&amp;id='.$id.'&amp;retmode=xml');
$geneName = $xmlGeneralData->DocumentSummarySet->DocumentSummary[0]->Name;
$geneDesc = $xmlGeneralData->DocumentSummarySet->DocumentSummary[0]->Description;
$geneChromosome = $xmlGeneralData->DocumentSummarySet->DocumentSummary[0]->Chromosome;
echo "Id: ".$id."
";
echo "Name: ".$geneName."
";
echo "Description: ".$geneDesc."
";
echo "Chromosome: ".$geneChromosome."
";?>

But, according with the profesor, this code doesn't use Xpath queries and is required that the page use it.

Someone can help me or explain me how to do it?

Here's converted code to Xpath query.

<?php

$text = $_REQUEST['text'];
$xmlId = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=gene&amp;term='.$text.'%5bGene%20Name%5d+AND+%22Homo%20sapiens%22%5bOrganism';

//Load XML and define Xpath
$xml_id = new DOMDocument();
$xml_id->load($xmlId);
$xpath = new DOMXPath($xml_id);

//Xpath query to get ID
$elements = $xpath->query("//eSearchResult/IdList/Id");

//Loop through result of xpath query and store in array of ID
if ($elements->length >0) {
    foreach ($elements as $entry) {
        $id[] = $entry->nodeValue;
    }
}

echo "Id: ".$id[0]."
";

//Output the first string of ID array from xpath result set
$xmlGeneralData = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=gene&amp;id='.$id[0].'&amp;retmode=xml';

//Load XML and define Xpath
$xml_gd = new DOMDocument();
$xml_gd->load($xmlGeneralData);
$xpath = new DOMXPath($xml_gd);

//Xpath query to search for Document Summary with first string of ID array from previous result set
$elements = $xpath->query("//eSummaryResult/DocumentSummarySet/DocumentSummary[@uid='".$id[0]."']");

//Loop through result of xpath query and find nodes and print out the result
if ($elements->length >0) {
    foreach ($elements as $entry) {
        echo "Name: ".$entry->getElementsByTagName('Name')->item(0)->nodeValue."
";
        echo "Description: ".$entry->getElementsByTagName('Description')->item(0)->nodeValue."
";
        echo "Chromosome: ".$entry->getElementsByTagName('Chromosome')->item(0)->nodeValue."
";
    }
}

?>