在flash中读取php生成的XML? [英] Reading php generated XML in flash?

查看:157
本文介绍了在flash中读取php生成的XML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是我们问题的第1部分 (在Flash中将动态生成的XML文件作为PHP加载)

Here is part 1 of our problem (Loading a dynamically generated XML file as PHP in Flash).

现在我们能够获取Flash读取XML文件,但我们只能看到当从实际的Flash程序测试(测试影片)时,Flash正确显示。但是,当我们在线上传我们的文件以预览Flash无法正确呈现时,会丢失一些重要信息(缩略图,标题,视频等)。

Now we were able to get Flash to read the XML file, but we can only see the Flash render correctly when tested(test movie) from the actual Flash program. However, when we upload our files online to preview the Flash does not render correctly, missing some vital information(thumbnails, titles, video etc..).

SWF文件存在于域1
XML& PHP文件都存在于域2
嵌入代码的HTML文件位于域3上

The SWF file exists on Domain 1 The XML & PHP file both exists on Domain 2 And the HTML file with the embed code lies on Domain 3

想知道这是否可能是一个跨域问题?我们有其中一个文件在域1&

Wondering if this could be a crossdomain issue? We have one of those files in place on Domain 1 & 2 where we have access too, however for Domain 3 we can't have a crossdomain.xml file there.

$xml = new XMLWriter();
$xml->openMemory();
$xml->setIndent(true);
$xml->setIndentString("\t");
$xml->startDocument();
$xml->startElement('data');
$xml->startElement('config');
    $xml->startElement('hex');
        $xml->writeCData('0x' . $widget_profile['background_color']);
    $xml->endElement();
    $xml->startElement('width');
        $xml->writeCData($widget_profile['width']);
    $xml->endElement();
    $xml->startElement('height');
        $xml->writeCData($widget_profile['height']);
    $xml->endElement();
    $xml->startElement('fullscreen');
        $xml->writeCData('false');
    $xml->endElement();
    $xml->startElement('special');
        $xml->writeCData('false');
    $xml->endElement();
    $xml->startElement('specialName');
        $xml->writeCData('Tools & Offers');
    $xml->endElement();
    $xml->startElement('specialLink');
        $xml->writeCData('XXXXXX');
    $xml->endElement();
    $xml->startElement('client');
        $xml->writeCData($widget_profile['site_url']);
    $xml->endElement();
$xml->endElement();

if (count($widget_content) > 0) {
    foreach ($widget_content as $tab) {
        $xml->startElement('tab');
        $xml->writeAttribute('id', $tab['tabname']);

        if (count($tab['video']) > 0) {
            foreach ($tab['video'] as $video) { 
                $video_sql = "select VID, flvdoname, title
                              from video 
                              where VID='" . $video . "'";

                $video_result = $howdini->query($video_sql);

                if ($video_result->rowCount() > 0) {
                    foreach ($video_result as $video_row) {

                        $video_row['flvdoname'] = substr($video_row['flvdoname'], 35, -4);

                        $xml->startElement('vid');
                        $xml->writeAttribute('flv', $video_row['flvdoname']);
                        $xml->writeAttribute('thumb', 'XXXXXXXXX' . $video_row['VID'] . '.jpg');
                        $xml->writeAttribute('title', $video_row['title']);
                        $xml->endElement();
                    }
                }

            }
        }

        $xml->endElement();
    }
}
$xml->endElement();
$xml->endDocument();
header('Content-Type: text/xml; charset=UTF-8');
echo $xml->flush();

感谢您提供任何答案!编辑:我包含了更改,现在Firebug看到的XML。现在它只是没有看到swf文件,但我可以看到页面的其他部分的swf文件。

Thanks in advance for any answers! I have included the change and now Firebug sees the XML. Now it's just not seeing the swf file but I can see the swf file in other parts of the page.

推荐答案

不是一个完整的解决方案,而只是一个数据点当我通过静态文件和PHP文件下载您的XML并进行差异化时,我得到以下结果:

Not a full solution, but just a data point (because encoding issues suck). When I downloaded your XML via the static file and PHP file and diffed them, I got the following results

% diff php.xml static.xml
1c1
< <?xml version="1.0"?>
---
> <?xml version="1.0"?>
10a11
>
19a21
>

您的静态文件在其开头有一个额外的非ASCII字符。

Your static file has an extra "non-ASCII" character at the start of it.

我的猜测是你的静态XML文件有一个UTF-8 BOM,PHP生成的文件不,并且你的flash电影期待一个UTF-8文件。我可以尝试使用您的PHP XML文件生成BOM ,并查看它帮助或处理您的服务器的编码设置。

My guess is your static XML file has a UTF-8 BOM that PHP generated file doesn't, and that your flash movie is expecting a UTF-8 file. I'd try generating a BOM with your PHP XML file and seeing it it helps, or fiddling with your server's encoding settings.

尝试更改PHP,以便输出以下标题(与嵌入电影的网页匹配)。

Try changing you PHP so it outputs the following header (matching the web page the movie is embedded in).

header('Content-Type: text/html; charset=UTF-8') 

这篇关于在flash中读取php生成的XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆