XML ayrıştırma hatası

0 Cevap php

Bir XML belge yazmak için bir PHP komut dosyası yazdım ama bir hata var:

 <?php
$db = "unadb";
$connection = mysql_connect("localhost", "root", "") or die("Could not connect.");
$table_name = 'article';

$db = mysql_select_db($db, $connection);
$query = "select * from " . $table_name;
$result = mysql_query($query, $connection) or die("Could not complete database query");
$num = mysql_num_rows($result);
if ($num != 0) {
 $file= fopen("results.xml", "w");
 $_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
 $_xml .="<atricle>";

 while ($row = mysql_fetch_array($result)) {
      $_xml .="\t<page>\r\n";
 if ($row["title"]) {
     $_xml .="\t<page title=\"" . $row["title"] . "\">\r\n";
     $_xml .="\t<source>" . $row["source"] . "</source>\r\n";
     $_xml .="\t<kw>" . $row["kw"] . "</kw>\r\n";
     $_xml .="\t\t<Url>" . $row["url"] . "</Url>\r\n";
     $_xml .="\t\t<author>" . $row["author"] . "</author>\r\n";
     $_xml .="\t<status>" . $row["status"] . "</status>\r\n";
     $_xml .="\t</page>\r\n";
 } else {
 $_xml .="\t<page title=\"Nothing Returned\">\r\n";
 $_xml .="\t\t<file>none</file>\r\n";
 $_xml .="\t</page>\r\n";
 } }
 $_xml .="</atricle>";

 fwrite($file, $_xml);
 fclose($file);

 echo "XML has been written.  <a href=\"results.xml\">View the XML.</a>";
 } else {
 echo "No Records found";

 } ?>

Çıktısı:

<?xml version="1.0" encoding="UTF-8" ?>
<atricle>   <page>
    <page title="Coming Race">
    <source>http://www.public-domain-content.com/books/Coming_Race/C1P1.shtml</source>
    <kw>home</kw>
        <Url>http://www.uberarticles.com/articles/artsubmit/upreview.php?article_id=580332</Url>
        <author>afnan</author>
    <status>active</status>
    </page>
    <page>
    <page title="Coming Race">
    <source>http://www.public-domain-content.com/books/Coming_Race/C1P1.shtml</source>
    <kw>home</kw>
        <Url>http://www.uberarticles.com/articles/artsubmit/upreview.php?article_id=580332</Url>
        <author>Doctor</author>
    <status>active</status>
    </page>
</atricle>

Ben XML Tamam ama bir hata olduğunu düşünüyorum:

Açılış ve etiket uyuşmuyor: sayfa satır 0 ve atricle sütun 11 18. satırda hata

0 Cevap