XML,类型错误:错误#1088:在标记 [英] XML, TypeError: Error #1088: The markup in

查看:329
本文介绍了XML,类型错误:错误#1088:在标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以看到最新错无论是code抢XML或XML文件本身?它看起来也形成了我,我没有看到错误的原因:

一个类型错误已发生:     类型错误:错误#1088:必须在良好的根元素下列文件中的标记

  var文件:字符串='的config.xml';
    VAR装载机:的URLLoader =新的URLLoader();
    VAR要求:的URLRequest =新的URLRequest(文件);
    loader.load(要求);
    loader.addEventListener(完整的,的onComplete);
    loader.addEventListener(ioError在onIOError);

    私有函数onIOError(事件:事件):无效
    {
        跟踪(IO错误(也许XML文件不存在或者有一个不正确的名字));
    }

    私有函数的onComplete(事件:事件):无效
    {
        VAR装载机:的URLLoader将event.target =为的URLLoader;
        如果(装载机!= NULL){
            尝试 {
                VAR设置:XML =新的XML(loader.data);
            }赶上(五:类型错误){
                跟踪(A类型错误已发生:\ r \ t+ E);
            }

        } 其他 {
            跟踪(Loader是不是一个的URLLoader!);
        }
    }
 

config.xml中

 < XML版本=1.0编码=UTF-8&GT?;
<设置>
    &其中;设置1→1&其中; /设置1>
    &其中; showDebug→2&其中; / showDebug>
    &其中; someOtherSetting→3&所述; / someOtherSetting>
< /设置>
 

解决方案

你创造什么,在XML文档?

我有类似的事情发生在前几天,取决于文本/ XML编辑器,它可以增加一个字节顺序标记到开始的维基百科BOM 。这瞬间的XML文件无效。尝试复制和粘贴你有什么到记事本中,并重新保存它。

或者,如果你有一个可用的Linux机器,物料清单将出现在VI作为'',你可以删除它。

此外,仅供参考,对BOM的UTF编码是'\ ufeff

Can anyone see whats wrong with either the code to grab the XML or the XML file itself? It looks well formed to me and I don't see the cause of the error:

A TypeError has occured: TypeError: Error #1088: The markup in the document following the root element must be well-formed.

    var file:String = 'config.xml';
    var loader:URLLoader = new URLLoader();
    var request:URLRequest = new URLRequest(file);
    loader.load(request);
    loader.addEventListener("complete", onComplete);
    loader.addEventListener("ioError", onIOError);

    private function onIOError(event:Event):void 
    {
        trace("IOERROR (maybe XML file does not exit or have an incorrect name)");
    }

    private function onComplete(event:Event):void 
    {
        var loader:URLLoader = event.target as URLLoader;
        if (loader != null) {
            try {
                var settings:XML = new XML(loader.data);
            } catch (e:TypeError) {
                trace("A TypeError has occured: \r\t" + e);
            }

        } else {
            trace("Loader is not a URLLoader!");
        }
    }

config.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings>
    <setting1>1</setting1>
    <showDebug>2</showDebug>
    <someOtherSetting>3</someOtherSetting>
</settings>

解决方案

What did you create the XML document in?

I had something similar occur the other day, depending on the text/xml editor it may add a Byte Order Mark to the beginning Wikipedia BOM . This instantly invalidates the XML file. Try copying and pasting what you have into notepad and re-saving it.

Or, if you have a Linux machine available, the BOM will appear in VI as '' and you can remove it.

Also, just for reference, the utf encoding for the BOM is '\ufeff'

这篇关于XML,类型错误:错误#1088:在标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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