A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: how to validate xml file in actionscript3.0???

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    1

    how to validate xml file in actionscript3.0???

    <note>
    <to>ahmad</to>
    <from>jhon
    <body>hello how are you!!!</body>
    </note>

    above is my xml file which have no ending tag of from tag. which id an error.
    i want an actionscript code to check if there is a broken tag then fix it automaticaly . and my code displays the correct xml.

    anyone who can help me???

    Thanks

    Regards
    Ahmad

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I never heard of that and I think I know why.

    It is not a good habit to have invalid files like an XML file when you develop a program.

    Also fixing the file permanently would require a server-side script like php. Probably what Adobe has created to give the error message may be something you are looking for.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    Jun 2010
    Location
    Boulder, CO
    Posts
    9

    Use "text" for result format

    When you create your HTTP service request, set the "resultFormat" attribute to "text". Then you'll receive a raw string, which you can parse by hand. You can use the XML and XMLLIST classes to help.

    If you use resultFormat = "xml" or "object" (the default) and attempt to load an invalid XML file, you'll get an error event FaultEvent.FAULT

    You must use the "text" resultFormat to get a look at the XML text.
    Sample code:

    httpService = new HTTPService();
    httpService.addEventListener(ResultEvent.RESULT,ht tpResultHandler);
    httpService.addEventListener(FaultEvent.FAULT,http FaultHandler);

    httpService.url = _url;
    httpService.requestTimeout = timeout;
    httpService.resultFormat = "text";
    httpService.send();

    private function httpResultHandler(event:ResultEvent):void {
    ...
    var textString:String = event.result

    private function httpFaultHandler(event:FaultEvent):void {
    ...

    Try it and let me know.
    Oz

Tags for this Thread

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