XML parsing error: undefined entity
When I opened the XML generated by PHP, I ran into this error: XML parsing error: undefined entity Location: http://www.mousebomb/Manage/xml.php?act=staticText&name=about Line: 1, Column: 84: H...
When I opened the XML generated by PHP, I ran into this error: XML parsing error: undefined entity Location: http://www.mousebomb/Manage/xml.php?act=staticText&name=about Line: 1, Column: 84: H...
I’m never one to back down from wrestling with the most bizarre problems—let’s see who comes out on top. It’s been ages since I hit an obstacle while coding, yet today I ran into a little snag—XML generated by PHP came out as garbled text when fetched with FLASH. After some digging I finally solved it. Recording it here, and also jotting down the general solution. If you also run into XML <-> FLASH garbled text, here’s a quick reference: 1. When you’re certain the XML is absolutely fine:First, FLASH reading XML and getting garbled text involves the static property System.useCodepage. Official description: “A Boolean value that tells Flash Player which code page to use to interpret external text files.” Defaults to false.
When you use httpService in Flex to read XML from a different domain (such as http://xml.weather.yahoo.com/forecastrss), you get a Security error accessing url error. But in the debug folder (bin-debug by default) it reads just fine. This is really annoying — I’m sure plenty of people have been tripped up by this security issue. Why does it only work in the debug folder? It turns out the bin-debug folder works only because [系统盘]:Documents and Settings[用户名]Application DataMacromediaFlash Player#SecurityFlashPlayerTrustflexbuilder.cfg sets it as trusted automatically. At actual runtime, it’s blocked by security. In other words, what we need to do is solve the security-block problem. So how do we fix it?
oEmbed is a brand-new spec, announced by Cal Henderson (Flickr), Mike Malone, Leah Culver (Pownce), and Richard Crowley (OpenDNS). oEmbed is an open format for standardizing how images, videos, links, or other media get embedded, and for sidestepping media providers’ APIs (or the screen scraping you’d need when they don’t have one). When a user posts a link that points straight at a specific media resource, it lets a site embed that media quickly and painlessly. Here’s how it works: it converts the link accordingly — that is, it turns the image or video into XML or JSON that tells you how to embed the media.