XML : how to give php-xml total count id

i have problem with xml and i am working with php. For me need total id. With this code get total id all products.

  $xmlArray = array();  foreach($xml->Product as $product) { $xmlArray[] = array("productID" => (string)$product->Book); }  $total = count($xmlArray);    

But for me need only php books total id, my codes for php books total id

  $xmlArray2 = array();  foreach($xml->Product as $product2) { $xmlArray2[] = array("PHP" => (string)$product->Book); }  $total = count($xmlArray2);    

but give total id all products. And all codes:

  $inPage = 10;  $currentRecord = 10;    $xml = new SimpleXMLElement('http://examplesite.com/xmlinfo.xml', 0, true);    $xmlArray = array();    foreach($xml->Product as $product) { $xmlArray[] = array("prouctID" => (string) $product->Book); }    $total = count($xmlArray);    $toplamPage = ceil($total / $inPage);    foreach($xml->Product as $value) {            if($value->Book == "PHP") {              $currentRecord += 1;              if($currentRecord > ($page * $inPage) && $currentRecord < ($page * $inPage + $inPage)) {                  echo '<div class="BrandTab">';                  echo '<a href="product.php?productID=' . $value->UrunID . '"><img src="' . $value->ImageName . '" style="width:130px;height:200px;/></a>';                  echo '<article>';                  echo '<div class="ok"></div>';                  echo '<p>' . $value->ProductName . '</p>';                  echo '</article>';                  echo '</div>';              }          }      }    

No comments:

Post a Comment