TypeError:错误#1088:根元素后面的文档中的标记必须格式正确。我无法找到错误的地方。
stop();
var city:String;
var par_id:String;
var key:String;
var units:String;
var data_xml_url:String = "data.xml";
var user_data:XML = new XML();
var data_url:URLRequest = new URLRequest(data_xml_url);
var dataLoader:URLLoader = new URLLoader(data_url);
dataLoader.addEventListener(Event.COMPLETE, dataLoaded);
function dataLoaded(e:Event):void
{
user_data = XML(dataLoader.data);
city = user_data.city.toString();
par_id = user_data.parid.toString();
key = user_data.key.toString();
units = user_data.units.toString();
}
icons_mc.visible = false;
var weather_xml_url:String = "http://xoap.weather.com/weather/local/"+city+"? cc=*&link=xoap&par="+par_id+"&key="+key+"&unit="+units;
var weather:XML = new XML();
var weather_url:URLRequest = new URLRequest(weather_xml_url);
var weatherLoader:URLLoader = new URLLoader(weather_url);
weatherLoader.addEventListener(Event.COMPLETE, weatherLoaded);
function weatherLoaded(e:Event):void
{
weather = XML(weatherLoader.data);
temp_txt.text = weather.cc.tmp;
icons_mc.visible = true;
var weather_icon:int = Number(weather.cc.icon.toString())+1;
icons_mc.gotoAndStop(weather_icon);
}
也许这是错误的:user_data = XML(dataLoader.data);
?
答案 0 :(得分:0)
首先要知道你在哪里得到错误,什么行,因为你正在加载不同的XML,数据和天气,但通常这个错误意味着加载原始XML结构的问题。尝试跟踪dataLoader.data和weatherLoader.data,然后再将它们分配给XML变量并查找XML字符串上的问题,很可能需要添加根级别
答案 1 :(得分:-1)
user_data = XML(dataLoader.data)错误。 使用此:
user_data = XML(e.target.data);