dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: AS3 loads xml (TypeError: Error #1088)

  1. #1
    Member
    Join Date
    Mar 2004
    Location
    singapore
    Posts
    75

    AS3 loads xml (TypeError: Error #1088)

    I experienced the following error when loading xml using AS3. I searched the whole internet for solutions but nothing works! But after trying for hours, i somehow solve it. All I did was to remove "</xml>" from my xml.

    TypeError: Error #1088: The markup in the document following the root element must be well-formed.
    at toffees_fla::MainTimeline/onLoaded()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

    This is my AS3 code:
    Code:
    var xmlLoader:URLLoader = new URLLoader();
    xmlLoader.addEventListener(Event.COMPLETE, onLoaded);
    
    var xmlData:XML;
    
    function onLoaded(e:Event):void {
    	xmlData=new XML(e.target.data);
    	trace(xmlData);
    }
    
    xmlLoader.load(new URLRequest("example.xml"));
    ORIGINAL xml:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>  
    
    <Accounts>
    
    	<Account>
    		<Username>TESTER 1</Username>
    		<Password>1234</Password>
    		<Link>http://www.google.com</Link>
    	</Account>
    
    	<Account>
    		<Username>TESTER 2</Username>
    		<Password>2134</Password>
    		<Link>http://www.yahoo.com</Link>
    	</Account>
      
    	<Account>
    		<Username>TESTER 3</Username>
    		<Password>3124</Password>
    		<Link>http://www.msn.com</Link>
    	</Account>
       
    </Accounts>
    
    </xml>
    EDITED xml:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>  
    
    <Accounts>
    
    	<Account>
    		<Username>TESTER 1</Username>
    		<Password>1234</Password>
    		<Link>http://www.google.com</Link>
    	</Account>
    
    	<Account>
    		<Username>TESTER 2</Username>
    		<Password>2134</Password>
    		<Link>http://www.yahoo.com</Link>
    	</Account>
      
    	<Account>
    		<Username>TESTER 3</Username>
    		<Password>3124</Password>
    		<Link>http://www.msn.com</Link>
    	</Account>
       
    </Accounts>
    Hope this is useful to anyone having this error.

    Cheers

  2. #2
    Junior Member
    Join Date
    Jan 2009
    Posts
    11
    The reason removing </xml> worked is because you don't have an opening <xml> to match the </xml>. What you have at the top is your XML declaration, not your root element.

  3. #3
    Member
    Join Date
    Mar 2004
    Location
    singapore
    Posts
    75
    oh! ya.. i dint think of that. I kept thinking <?xml version="1.0" encoding="UTF-8"?> is the opening tag and </xml> is the closing tag.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center