A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: error checking XML file??

  1. #1
    Member
    Join Date
    Aug 2001
    Posts
    33

    error checking XML file??

    I've got an XML file that I've loaded into Flash using the code:

    objXML = new XML();
    objXML.ignoreWhite = true;
    objXML.onLoad = parseXMLData;
    objXML.load("data.xml");

    The parseXMLData code:

    function parseXMLData(success) {
    if (success) {
    //goes through each node and builds an array of objects for use
    }
    }

    Everything works fine when the XML is as it is suppose to be (well formed).

    How do I check if the XML file is well formed before I use it? I want to trap bad files from coming in so that I can show an error message detailing what's wrong with the XML file.

    Please help.

    Thanks.

  2. #2
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    How bad is bad? valid XML but not what you are expecting or are you talking about when someone saves a picture and names it .xml. Flash will handle the latter, you will have to code for the former.

    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  3. #3
    Member
    Join Date
    Aug 2001
    Posts
    33
    Bad meaning missing brackets in the tags, missing end tags, etc. How do I code to check this?

    Thanks!

  4. #4
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    Typically flash won't parse the code, success variable in your parseXMLData function will be false.

    Flash is lenient with some things in XML that I know Java parsers will stop on (multiple root tags being one of them that flash accepts), but will stop for really badly formed xml.
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

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