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
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