Я пытаюсь сравнить значение узла и проанализировать значения атрибута xml, используя PHP DOM XML.
Ниже приведено то, что у меня есть на моей странице, но я больше не получаю результаты или ошибку.
PHP:
<?PHP
error_reporting(E_ALL);
ini_set("display_errors", 1);
//PRODUCT URL
$xml_url = "http://<servername>/services/info?storeId=2;
//LOCAL TEST URL
//$xml_url = "testXML.xml";
$xmlDoc = new DOMDocument();
$xmlDoc->load($xml_url);
//THIS IS WHERE MY ISSUE IS (I THINK)
$errorCheck = $xmlDoc->getElementsByTagName( "testcode"" );
$errorValue = $errorCheck->item(0)->nodeValue;
if ($errorValue != "1"){
//loop and show data
$grads = $xmlDoc->getElementsByTagName( "$grads" );
foreach( $grads as $grad )
{
$students = $grad->getElementsByTagName( "student" );
$student = $students>item(0)->nodeValue;
$times = $grad->getElementsByTagName( "time" );
$time = $times->item(0)->nodeValue;
echo "<tr><td>".$student."</td><td>".$time."</td></tr>";
}
}else{
?>
<H1> Show an html message</H1>
<?
}
?>
ЭТО МОЙ ТЕСТ XML:
<response>
<testcode>0</testcode>
<grad student="mike" time="10:00am"/>
<grad student="Bob" time="11:00am" />
<grad student="TOM" time="11:30am" />
<grad student="Greg" time="1:00pm" />
</response>