MYSQL データを XML (CSS を使用してスタイル設定) に変換する PHP スクリプトがあります。ページに HTML テキストとリンクが表示されるように、このページに HTML を少し追加する必要があります。次のようなエラーを返さずに、それらをphpスクリプトに追加するにはどうすればよいですか。
このページには次のエラーが含まれています: 行 44 の 1 列目のエラー: ドキュメントの末尾にある余分なコンテンツ 以下は、最初のエラーまでのページのレンダリングです。
できるだけ説明的で明確であることができれば、それは非常に役立ちます. ありがとう
phpスクリプトは次のとおりです。
<?php
header("Content-type: text/xml");
$host = "###";
$user = "###";
$pass = "###";
$database = "###";
$xslt_file = "/xmlstyle.css";
$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database.");
$query = "SELECT * FROM users WHERE Username = 'Username4';";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
$xml_output = "<?xml version=\"1.0\"?>\n";
//$xml_output .= "<?xml-stylesheet href=\"$xslt_file\" type=\"text/xsl\" ?
$xml_output .= "<?xml-stylesheet href=\"$xslt_file\" type=\"text/css\" ?>";
$xml_output .= "<Users>\n";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= "\t<Person>\n";
$xml_output .= "\t\t<Username>" . $row['username'] . "</Username>\n";
$xml_output .= "\t\t<Firstname>" . $row['firstname'] . "</Firstname>\n";
$xml_output .= "\t\t<Lastname>" . $row['lastname'] . "</Lastname>\n";
$xml_output .= "\t\t<Title>" . $row['Title'] . "</Title>\n";
$xml_output .= "\t\t<Description>" . $row['Description'] . "</Description>\n";
$xml_output .= "\t\t<Location>" . $row['Location'] . "</Location>\n";
$xml_output .= "\t\t<Feeling>" . $row['Feeling'] . "</Feeling>\n";
// Escaping illegal characters
$row['text'] = str_replace("&", "&", $row['text']);
$row['text'] = str_replace("<", "<", $row['text']);
$row['text'] = str_replace(">", ">", $row['text']);
$row['text'] = str_replace("\"", """, $row['text']);
$xml_output .= "\t</Person>\n";
}
$xml_output .= "</Users>";
echo $xml_output;
?>
表示したい HTMl のいくつかの例を次に示します。
<a href="http://www.w3schools.com">Visit W3Schools</a></br><hr noshade size="1" width="90%" align="center">
<a href="http://www.w3schools.com">Visit W3Schools</a></br><hr noshade size="1" width="90%" align="center">
<a href="http://www.w3schools.com">Visit W3Schools</a></br><hr noshade size="1" width="90%" align="center">
<a href="http://www.w3schools.com">Visit W3Schools</a></br>