Why doesn't XML-PHP process my HTML parameters?
<p>'
Hi,</p>

<p>doing some PHP programming, ran into a BIG issue, my book says:</p>

<pre><code>&lt;?xml version="1.0"?&gt;
&lt;catalog&gt;
 &lt;book category="children"&gt;
  &lt;title&gt;Harry Potter&lt;/title&gt;
  &lt;author&gt;J K. Rowling&lt;/author&gt;
 &lt;/book&gt;
 &lt;book category="computers"&gt;
  &lt;title&gt;XQuery Kick Start&lt;/title&gt;
  &lt;author&gt;James McGovern&lt;/author&gt;
  &lt;author&gt;Per Bothner&lt;/author&gt;
  &lt;author&gt;Kurt Cagle&lt;/author&gt;
  &lt;author&gt;James Linn&lt;/author&gt;
  &lt;author&gt;Vaidyanathan Nagarajan&lt;/author&gt;
 &lt;/book&gt;
 &lt;book category="cooking"&gt;
  &lt;title&gt;Breakfast for Dinner&lt;/title&gt;
  &lt;author&gt;Amanda Camp&lt;/author&gt;
 &lt;/book&gt;
 &lt;book category="finance"&gt;
  &lt;title lang="en"&gt;Learning XML&lt;/title&gt;
  &lt;author&gt;Erik T. Ray&lt;/author&gt;
 &lt;/book&gt;
&lt;/catalog&gt;
</code></pre>

<p>I had to change it to this to get it working:</p>

<pre><code>&lt;?php
header("Content-Type:text/xml");
?&gt;
&lt;&lt;??&gt;?xml version="1.0"?&gt;
&lt;catalog&gt;
 &lt;book category="children"&gt;
  &lt;title&gt;Harry Potter&lt;/title&gt;
  &lt;author&gt;J K. Rowling&lt;/author&gt;
 &lt;/book&gt;
 &lt;book category="computers"&gt;
  &lt;title&gt;XQuery Kick Start&lt;/title&gt;
  &lt;author&gt;James McGovern&lt;/author&gt;
  &lt;author&gt;Per Bothner&lt;/author&gt;
  &lt;author&gt;Kurt Cagle&lt;/author&gt;
  &lt;author&gt;James Linn&lt;/author&gt;
  &lt;author&gt;Vaidyanathan Nagarajan&lt;/author&gt;
 &lt;/book&gt;
 &lt;book category="cooking"&gt;
  &lt;title&gt;Breakfast for Dinner&lt;/title&gt;
  &lt;author&gt;Amanda Camp&lt;/author&gt;
 &lt;/book&gt;
 &lt;book category="finance"&gt;
  &lt;title lang="en"&gt;Learning XML&lt;/title&gt;
  &lt;author&gt;Erik T. Ray&lt;/author&gt;
 &lt;/book&gt;
&lt;/catalog&gt;
</code></pre>

<p>but now my book says that if I use <a href="http://www.ed-dyreen.com/books.php?category=cooking" rel="nofollow">http://www.ed-dyreen.com/books.php?category=cooking</a> I should get the output filtered by category,
well it's not doing that at all, see for yourself in the above link-></p>

<p>do u guys have any ideas, ...</p>

<p>:(</p>

<p>'
Thankx for the replies,</p>

<p>Or did the book say that PHP does automatic XML extraction per GET parameters?</p>

<p>The book didn't indicate I would have to it manually..</p>

<p>I expected that
<a href="http://www.ed-dyreen.com/books.php?category=cooking" rel="nofollow">http://www.ed-dyreen.com/books.php?category=cooking</a></p>

<p>would give me this output:</p>

<pre><code> &lt;book category="cooking"&gt;
  &lt;title&gt;Breakfast for Dinner&lt;/title&gt;
  &lt;author&gt;Amanda Camp&lt;/author&gt;
 &lt;/book&gt;
</code></pre>

<p>because later on in the book the parameter is used and the book example filter does nothing ???</p>

<pre><code>function categoryClick () {
    new Ajax.Request ( "books.php", {
        method: "GET",
        onSuccess: showbooks,
        parameters: {category: this.innerHTML},
        onFailure: ajaxFailed,
        onException: ajaxFailed
    });
}
</code></pre>

<p>and then it shows all results instead of just the ones that match parameters ?</p>

<pre><code>function showcategories ( ajax ) {
    var categories = ajax.responseXML.getElementsByTagName("category");
    for (i=0;i&lt;categories.length;i++) {
      var categoryName = categories[i].firstChild.nodeValue;
      var li = document.createElement("li");
      li.innerHTML = categoryName;
      li.onclick = categoryClick;
      $('categories').appendChild(li);
    }
}
function showbooks ( ajax ) {

    var books = ajax.responseXML.getElementsByTagName( "book" );
alert (books.length);
    for (i=0;i&lt;books.length;i++) {

        var titleNode  = books[i].getElementsByTagName( "title" )[0];
        var authorNode = books[i].getElementsByTagName( "author" )[0];
        var title      = titleNode.firstChild.nodeValue;
        var author     = authorNode.firstChild.nodeValue;

        var li = document.createElement("li");
        li.innerHTML = title + ", by" + author ;

        $('books').appendChild(li);
    }
alert ("test0");
}
</code></pre>

<p>I am a newbie.</p>

<hr>

<p>'
This is what I have now:</p>

<pre><code>&lt;?php
 header("Content-Type:text/xml");
 global $category;
 $category = htmlspecialchars( $_GET["category"] ); #prevent HTML injection

 echo "&lt;?xml version=\"1.0\"?&gt; \n";

 if ( $category == ""  ) {
   echo "&lt;categories&gt; \n";
   echo "&lt;category&gt;children&lt;/category&gt; \n";
   echo "&lt;category&gt;computers&lt;/category&gt; \n";
   echo "&lt;category&gt;cooking&lt;/category&gt; \n";
   echo "&lt;category&gt;finance&lt;/category&gt; \n";
   echo "&lt;/categories&gt; \n";
 };

?&gt;
</code></pre>

<p>But it's a lot of work, is there a way to process HTML parameters without having to hard-code them in the php file ?</p>

<p>This what I have now:
<a href="http://www.ed-dyreen.com/books.php" rel="nofollow">http://www.ed-dyreen.com/books.php</a>
And this is the example I am trying to reproduce:
<a href="http://webster.cs.washington.edu/books.php" rel="nofollow">http://webster.cs.washington.edu/books.php</a></p>

<p>In the example link if you add ?categoy=cooking, you get something completely different.
HOW ARE THEY DOING THAT ??</p>
