今天和朋友发现一个flash读取xml的权限问题

当一个flash需要读取外部xml时,在本机上读取网络上的xml没有问题,放上网站就无法读取~~~~~~~~~

这个是令人郁闷的问题.

我们首先怀疑xml的格式问题,更改xml格式无效.问题依旧.

我们采用换xml存放的域名地址,问题依旧.

我们把xml从linux挪到window上上,问题依旧.

把apach换到iis,自己架iis,xml放flash同目录,问题依旧.

这是发现,把xml弄到本地,从iis上可以读取.

于是我们怀疑是服务器或域问题,想想MM公司不可能傻到只为MS服务,所以我们把问题锁定于域的问题上

朋友上网查了资料才发现:flash读取异域是禁止的,可能是处于安全问题..................//ps:偶不是开发flash的.咔咔

不过只要加上一个东西就可以解决.

试了多种方法,终于找到原因:跨域读取问题---------

解决方案为:

在域名根目录加上:crossdomain.xml的文件,这个文件用于配置flash跨域读取的权限问题.内容如下:

<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>

终于解决一个无厘头问题.咔咔....舒服.

写这文章备忘一下,希望能给有需要的朋友一点帮助

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下面是一个示例类,演示了如何封装一个支持重载赋值运算符、读取和写入节点属性的类,使用Pugixml库: ```cpp #include <iostream> #include <string> #include "pugixml.hpp" class XMLNode { public: XMLNode(const std::string& filePath) { document.load_file(filePath.c_str()); } // 重载赋值运算符 XMLNode& operator=(const XMLNode& other) { if (this != &other) { document.reset(); document = other.document; } return *this; } template<typename T> T getProperty(const std::string& nodeName, const std::string& attributeName) { pugi::xml_node node = document.child(nodeName.c_str()); if (node) { pugi::xml_attribute attr = node.attribute(attributeName.c_str()); if (attr) { return attr.as_string(); } } // 返回默认值或抛出异常,根据需要自行决定 return T(); } template<typename T> void setProperty(const std::string& nodeName, const std::string& attributeName, const T& value) { pugi::xml_node node = document.child(nodeName.c_str()); if (!node) { // 创建新节点 node = document.append_child(nodeName.c_str()); } node.append_attribute(attributeName.c_str()).set_value(value); } void save(const std::string& filePath) { document.save_file(filePath.c_str()); } private: pugi::xml_document document; }; int main() { XMLNode xmlNode1("example.xml"); // 读取属性 std::string author = xmlNode1.getProperty<std::string>("book", "author"); int year = xmlNode1.getProperty<int>("book", "year"); std::cout << "Author: " << author << std::endl; std::cout << "Year: " << year << std::endl; // 创建新的XMLNode对象并赋值 XMLNode xmlNode2("another_example.xml"); xmlNode2 = xmlNode1; // 修改属性 xmlNode2.setProperty("book", "author", "John Doe"); xmlNode2.setProperty("book", "year", 2022); // 保存修改后的内容 xmlNode2.save("modified_example.xml"); return 0; } ``` 在这个示例中,XMLNode类封装了一个pugixmlxml_document对象,并提供了getProperty()和setProperty()成员函数来读取和写入节点属性。它还重载了赋值运算符,使得一个对象可以将其数据赋值给另一个对象。在main函数中,我们创建了两个XMLNode对象,分别加载了不同的XML文件,并演示了如何读取属性、修改属性、赋值和保存修改后的内容。 请注意,这只是一个简单的示例,你可以根据自己的需求对XMLNode类进行扩展和修改。同时,需要注意Pugixml的内存管理和异常处理等问题
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值