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

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

Problem:
The XML class has found an error with the XML data you are supplying it.

Cause:
Typical causes are that the XML is not valid. The most common problem I see is when an XMLNode singleton is not closed. For example,



  




  

Notice how the “myxml” child node does not have a closing slash at the end. This xml is not well formed.

Other causes are that the xml file or content is not even there or there is an error on the server and you are getting the error message returned and not the xml.

To easily figure out what is going on inspect the information that is supposed to be XML data. I’ll say it again, INSPECT THE XML THAT IS COMING BACK FROM THE SERVER. You can see the return data in the console in Flash / Flex Builder. If you are using a HTTPService call set the result format property to “text” instead of “xml” / “e4x” and trace the output in the result handler. I think it is trace(event.result) when it is in the result handler.


	
	

You may also have characters before or after the root XML tag:


   <-- some blank spaces or new line characters could be here 



   <-- some blank spaces or new line characters could be here

Please reply in the comments below if this helped you or not. You can also use the Error Lookup to look up Flex compiler or runtime errors.

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

50 thoughts on “Error #1088: The markup in the document following the root element must be well-formed.

  1. Schreuder says:

    An xml produced with a text editor that concludes the file with the (DOS) traditional end-of-file character (0x1A) might put you on the wrong foot.
    Anyhow, the developers would do a magnificent job by adding the line number where the error was found.

    Like

  2. Prajakta Godbole says:

    I am trying to use the yahoo api for some application I am trying to build on Flex Builder 2. But, the cross-domain-policy tag seems to be giving the error ” The mark-up in the document follwing the root element must be well-formed”. I tried to look up for this every place possible. Please let me know if you know why I am getting this.

    Like

  3. Judah says:

    @Prajakta – It could be that the xml file is not found or in the wrong location. Also make sure that ” is the very first item in the file. Check for spaces. It may be best to create a new file and then retype in the xml.

    Like

  4. Nick says:

    i’m getting this 1088 error and I can’t figure it out! I’ve changed the result format to “text” and traced the result from the result Handler but other errors are appearing. Could you please post or email me an exact step by step way to solving this issue? It’s driving me insane!!

    Like

  5. Judah says:

    @Nick – I contacted you at your email and it bounced. Anyway, take the result that you are getting from the server and paste it into Dreamweaver. Dreamweaver has a feature that checks the validity of an xml document. Create a new xml document, paste in the results and then run the validator. It will tell you if it is valid xml or not.

    Like

  6. Gordon says:

    In case anyone else has this issue due to similar circumstances, Schreuder’s advice paid off for me. I use FlashDevelop for my Flex/AIR IDE (it’s great for a free IDE), and this 1088 runtime error started popping up.

    I was loading an XML file that I had created using EditPlus, and it was working fine. As soon as I created a new XML file with FlashDevelop and loaded it, up came the 1088 error. After going over and over the markup and finding no errors, I saw Schreuder’s comment about EOF characters. I recreated the XML file in EditPlus and it worked!

    I tried changing all of the end-of-line settings in FlashDevelop but nothing seemed to fix this. So, I’ve ended up using a different text editor to create XML files. Once they are created, I can edit them in FlashDevelop with no problems.

    Hope this helps someone.

    Like

  7. i’ve solved using the information founded here by adding this two lines before parsing the string

    var content:String = “our xml code”;
    content = content.substring(content.indexOf(“More here

    thanks a lot!

    Like

  8. I have made several flex app. and this have never happen to me
    if i run the resultFormat on xml, or text i dont get any error and i can see the event.result.toString() returnig the xml file as soon as i change the resultFormat to e4x i get the 1088 Error any ideas??

    Regards

    Jorge

    Like

  9. Judah says:

    Hi Jorge,
    Here’s two things you can try,
    Check if the XML is valid. You can do this by passing in the url at this page or pasting in the XML, http://www.w3schools.com/XML/xml_validator.asp.
    Or as Fabio and agosta mentioned at this post, http://www.artbits.it/?p=55, you can set the content type to text, check it when it comes back from the server and manually remove any invalid characters that were created somewhere along the process,
    [as]
    // remove any text or characters before the start of the xml markup
    rawContent = rawContent.substring(rawContent.indexOf(“<"),rawContent.length);
    // Convert linebreaks to something that the Flex XML parser can handle
    rawContent = rawContent.replace("rn","n");
    var xml:XML = XML(rawContent);
    [/as]
    This syntax highlighter looks like crap in the comments. 😛

    Like

  10. Hi Judah
    the problem was DB connection i was checking the php that generates the
    xml but forgot to check the connection parameters

    😦

    thanks for your help

    Regards

    Jorge

    Like

  11. bharti says:

    Hey Judah,
    I am running xml file Flex application and I was getting the same error.I checked my xml through xml_validator.Validator is showing no error in the xml.
    Please help me to get rid of the problem

    Like

  12. Hi Judah,
    in my air-flex application have experience that error too, it seems like I don’t really understand the async method, so when the database connection screwed up the xml have been downloaded isn’t in complete form, that’s why the error persist right? because when I refresh it, it’s just fine.
    what I’m confuse is what should I tell to error dialogue to client so that they didn’t put it as fatal error? any suggestion? or am I really have to learn the async. because this only happen when it’s directly sync..

    Like

  13. Judah says:

    @arthipesa – i think that is right. i’m not sure the details of your situation but if you were making a httpservice call it could be numerous reasons. you must listen for the result event on your async calls before setting the data. you might also binding to the result property instead of the lastResult property.

    what i would do is add an event listener to listen for the result event. set the resultFormat to text (http://livedocs.adobe.com/flex/2/langref/mx/rpc/http/HTTPService.html#resultFormat). in the result event cast the data as xml there but put it in a try catch block.

    try {
    var myXML:XML = new XML(event.result);
    }
    catch {
    // not formed well refresh or something
    }

    Like

  14. hmm, thank you for the idea, you’re the best!
    You were right about the lastResult property, I was using lastResult property at all my httpservice call, I thought that’s better, guess it’s served for other reason, not the one in my head. I’ll give it a try, and when it’s done-should be by next 48hours exact-I’m gonna share with you again Judah.

    Like

  15. eleni says:

    i supose that i have promblem with this command at adope flex builder 3.i am new at the use of flex.Could anyone please post or email me an exact step by step way to solving this issue? It’s driving me insane!!

    Like

  16. Valy-D says:

    I kinda like this flex air technology though, until I bumped on the #1088 error. I thought I could solved it less than 10 min, but here I am 2 days later jumping blogs for answer.

    I did: Install wamp, create a DB (my_cd_db) import my xml cd_info into the new table my_cd_info. I did the proper test, also from the console (select *…..) works fine. Then, in flex: create a new project PHP_CD || application type = AIR || server tech…..= PHP. || next || web root = c:wampwww || root….=http://localhost || validation = OK || compile loca…= c:wampwwwPHP_CD-debug || Finish.

    Then : menu Data|| create appl…from DB || create a new conn name = to_mysql || host = localhost ||DBname = my_cd_db || username= root || passw=’’ (blank)|| test conn…=OK || I can see the conn, table and primary key || next 2x || finish

    I went and check what was created and I can only say that adobe did a great job putting all these codes together, I would have take me a week to get it as nice as them.

    BUT, IT IS NOT WORKING!!!. And I can’t get my hands on the problem.

    Oh, HI Judah, do you have anytime to help here.

    Like

  17. Judah says:

    @Valy-D: Check the data coming back from the server. I think that data may be incorrect. If I were you I would download the Flash Builder 4 beta and use the Network Monitor panel. It will show you how to check the data being sent. There are links to download it at labs.adobe.com and tutorials on using Network Monitor in the help file and a few blogs online.

    Like

  18. TonyMO says:

    I get the same problem with Valy-D using wamp and create appl…from DB. It will come out the Error. Then I debug the code adobe generate.Step by step, but I find no error about the codes. But when I use FLEX3 , to do a simple demo loading database metadata, it works well. So i suspect the function and wamp. But I find an exmaple in lynda.com tutorial which can work well using wamp and create appl..from DB. So I have no idea about what it’s going on.

    Like

  19. TonyMO says:

    Finally, I solve the problem which Valy-D refered to.
    I check PHP setting. Go to the file php.ini and set the “display-error” to Off.
    It can display:) I think you can work, Valy-D

    Like

  20. Mohd Riaz says:

    flex learner… facing error error-1088..
    for solveing it i go to wampserver -> php -> php.in and change “display-error” to Off and reset all the service .. now i can see all the data from database.

    Like

  21. Tejas says:

    Hello,

    I am generation an XML file in my application.
    Which looks something like this.

    test1
    XX

    test2
    YY

    but at the end of complilation of my application i get an error saying

    SystemId Unknown; Line #10; Column #10; The markup in the document following the root element must be well-formed.
    Any idea what might solve this.

    Thanks in Advance,
    Tejas

    Like

  22. Valy-D says:

    I forgot to thank Judah and TonyMO. Guys, I’m testing with Flashbuilder 4 beta 2 and always trying the nightly builds. I can only says that the time is almost almost almost right for me to put all other RIA tools and desktop application-dev tools (client/server) far away. Please everyone, follow Judah advise and go to Flashbuilder 4.

    Like

  23. Jessy says:

    I am facing the same problem that TonyMO and Valy-D had. I’m using wamp and create Flex3 web application. I tried setting the php.in and changed “display-errors” to Off and reset all the service, but it did’t work.
    Did anyone know other solutions for this “Connection error #1088” ?
    Please help me…Thanks a lot!!

    Like

  24. Mike M says:

    I am getting the infamous #1088 error that occurs with an application built from the Flex 3, Data->Create Application from Database menu item. The connection is valid and the data in the db is good.
    This utility builds a complete application consisting of an mxml file and an .as file connected to it. The completion event for the mxml file never fires before the error occurs. Any Ideas?

    Like

  25. memory says:

    i have air app test , it load xml file show this error Error #1088.

    rawContent.substring(rawContent.indexOf(“<"),rawContent.length);
    rawContent = rawContent.replace("rn","n");

    this code worked . thanks Judah 😉

    Like

  26. I have got the same problem which Mike M has described Scratching my head for last two weeks but nothing works. It halways throw error 1088. DB connection is good. Somebody please help.

    Like

  27. Rahul Bauskar says:

    @Mike.M
    @ Richie

    for the ones having issue with Error #1088 when using “Create Application from Database”, try using the 5.2.9 version of php from wampserver.com. You can switch between different addons from the wamp server interface.
    Worked for me.

    Like

  28. Nirmal Shukla says:

    Hi,
    Steps to fix the issue on wampserver.
    click on the wampserver icon on the notification area.
    Go to PHP >> PHP Settings >> Turn Off display errors.

    This will fix the Connection Error: Error# 1088 issue.

    Thanks

    Like

  29. Hi,
    Steps to fix the issue on wampserver.
    click on the wampserver icon on the notification area.
    Go to PHP >> PHP Settings >> Turn Off display errors.

    This will fix the Connection Error: Error# 1088 issue.

    Thanks

    –> Great things i read! Many thanks

    Like

  30. cerebrotecnologico says:

    For users of flex as a client of webservices, the reason may be that your server is MTOM enabled. Flex does not support MTOM.

    Like

  31. MikeP says:

    Like many others, the #1088 error was driving me crazy. I’d traced the data returned in ‘loader.data’ and that had validated as well structured xml. Tried all the other suggested fixes re: headers, etc.

    But Judah’s solution was the one that worked. So many thanks Judah and here’s the full working code that did the job for me Hope it saves someone a few headaches!

    //*****************************************************************************

    import flash.net.URLLoader;
    import flash.events.Event;
    import flash.net.URLVariables;
    import flash.net.URLRequest;

    var phpFile:String=”http://myphp.php”;

    function loadHandler():void
    {
    var urlrequest:URLRequest = new URLRequest(phpFile);
    var urlLoader = new URLLoader();
    urlLoader.addEventListener(Event.COMPLETE, callServerHandler);
    urlLoader.load(urlrequest);
    }

    function callServerHandler(e:Event):void
    {

    var loader:URLLoader = URLLoader(e.target);
    var rawContent:String = String(loader.data);

    /*If you were to trace (rawContent) at this stage and copy/paste this to an XML validator it would validate. But without the following steps that Judah supplied to remove certain characters it will return the #1088 in Flash.
    */

    //remove any text or characters before the start of the xml markup
    rawContent = rawContent.substring(rawContent.indexOf(“<"),rawContent.length);

    // Convert linebreaks to something that the Flex XML parser can handle
    rawContent = rawContent.replace("rn","n");

    var myxml:XML = XML(rawContent);

    /*myxml..department and department.name are specific to my xml content. Change to match the name of the main repeating node and subnodes in your xml
    */

    for each (var department in myxml..department)
    {
    trace("Department:" + department.name);
    }

    }
    loadHandler();

    //***********************************************************************

    Like

  32. For everyone using Flex or AS3: Error #1088 occurs when you try to convert a string to XML and the string itself is invalid XML. For XML to be valid, it should consist of one root node that may or may not contain other nodes or just text. If there is a chance your string might contain multiple (root) nodes without a parent node wrapped around them, then use the XMLList class instead.

    So instead of

    var yourVar:XML = XML(yourString);

    use

    var yourVar:XMLList = XMLList(yourString);

    It took me 5 days of trying all sorts of crazy things to resolve that error and finally this was the solution I needed.

    As for turning off the display of errors, I don’t see any wisdon in that. You would want to know if you have errors in your code.

    Like

Leave a comment