1

I am trying to write xml using dom.
but php code that makes xml using dom makes error.

prototype.js:1739 GET http://localhost/booksearch/books.php?category=children 500 (Internal Server Error)

before php code creates xml about books change to dom style, there is no error.
What makes this error?

$xmldom = new DOMDocument();
$books_tag = $xmldoc->createElement("books");
$xmldom->appendChild($books_tag);
$lines = file($BOOKS_FILE);
for ($i = 0; $i < count($lines); $i++) {
    list($title, $author, $book_category, $year, $price) = explode("|", trim($lines[$i]));
    if ($book_category == $category) {
        $book_tag = $xmldom->createElement("book");
        $category_tag = $xmldom->crateElement("category");
        $category_tag->appendChild($xmldom->createTextNode($category));
        $book_tag->appendChild($category_tag);
        $title_tag = $xmldom->createElement("title");
        $title_tag->appendChild($xmldom->createTextNode($title));
        $book_tag->appendChild($title_tag);
        $author_tag = $xmldom->createElement("author");
        $author_tag->appendChild($xmldom->createTextNode($author));
        $book_tag->appendChild($author_tag);
        $year_tag = $xmldom->createElement("year");
        $year_tag->appendChild($xmldom->creatTextNode($year));
        $book_tag->appendChild($year_tag);
        $price_tag = $xmldom->createElement("price");
        $price_tag->appendChild($xmldom->creatTextNode($price));
        $book_tag->appendChild($price_tag);
        $books_tag->appendChild($book_tag);
    }
}
header("Content-type: text/txt");
echo $xmldoc->saveXML();
Lawrence Cherone
  • 46,049
  • 7
  • 62
  • 106
Ben Kwon
  • 21
  • 2

0 Answers0