【发布时间】:2014-11-03 19:25:59
【问题描述】:
我有以下XML 文件:
<?xml version="1.0" encoding="UTF-8"?>
<?php
header('Content-type: application/xml');
require_once('includes/pdo_connection.php');
$query = "Select * from photo_category WHERE status='A'";
$result = DB::instance()->prepare($query)->execute()->fetchAll();
$output="<juiceboxgallery galleryTitle='FutureFit Gallery'>";
foreach($result as $row) {
$cat_id = $row['id'];
$cat_name = $row['photo_category_name'];
$query2 = "Select * from photogallery WHERE pcID = '$cat_id' AND status = 'A' order by id desc";
$result2 = DB::instance()->prepare($query2)->execute()->fetchAll();
foreach($result2 as $row2) {
$imgCaption = $row2['img_label'];
$thumb = $row2['thumb_img'];
$large = $row2['photo_gallery_image'];
$output .= "<image imageURL='images/photogallery/large/$large'
thumbURL='images/photogallery/thumb/$thumb'
linkURL=''
linkTarget='_blank'>
<title>".$imgCaption."</title>
</image>";
}
}
$output .= "</juiceboxgallery>"; ?>
<?php echo $output; ?>
在.htaccess我使用如下:
<IfModule mod_php5.c>
<FilesMatch "\.xml$">
SetHandler application/x-httpd-php
</FilesMatch>
</IfModule>
现在,当我在服务器上运行此 XML 时,我收到 XML 格式不正确的错误消息。错误如下:
XML Parsing Error: not well-formed
$output= '<juiceboxgallery galleryTitle="FutureFit Gallery">';
在 Chrome 中,错误显示:
error on line 6 at column 50: Document is empty
请帮我解决这个问题。
【问题讨论】:
-
看看这个 [thread][1] 我想你会从那里找到你的解决方案。 [1]:stackoverflow.com/questions/4075742/regex-to-strip-html-tags