media @ VU
[] readme course preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthoughts appendix references examples resources _

talk show tell print

ajax-cd.php



  <?php
  
  q=_GET["q"];
  
  xmlDoc = new DOMDocument();
  xmlDoc->load("xml-cd.xml");
  x=xmlDoc->getElementsByTagName('ARTIST');
  
  

process


  
  for (i=0; i<=x->length-1; i++)
  {                                 // process only element nodes
  if (x->item(i)->nodeType==1)
    {
    if (x->item(i)->childNodes->item(0)->nodeValue == q)
      { 
      y=(x->item(i)->parentNode);
      }
    }
  }
  
  

child nodes


  
  cd=(y->childNodes);
  
  for (i=0;i < cd->length;i++)
  { 
  // echo("trying");
  //Process only element nodes
  if (cd->item(i)->nodeType==1)
    { 
    echo("<b>");
    echo(strtolower(cd->item(i)->nodeName));
    echo("</b>");
    echo(": ");
    echo(cd->item(i)->childNodes->item(0)->nodeValue);
    echo("<br />");
    } 
  }
  ?>
  


(C) A. Eliëns 21/5/2007

You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.