PDA

View Full Version : Parsing html page


srinivasaraju
05-22-2008, 01:55 PM
Hi,

How to parse html page using flex3.0 and adobe AIR

could u explain with example ?

Thanks,
Srinivas

drkstr
05-22-2008, 03:47 PM
You could use the URLLoader class to load the page as text, then use regular expressions to parse it.

private function loadPage( url:String ): void {
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest( url );

loader.addEventListener(Event.COMPLETE, loadPageComplete);

loader.load(request);
}

private function loadPageComplete( event:Event ): void {
var pageText:String = String(event.target.data);
var paragraphs:Array = pageText.match( /<p>.*<\/p>/gi );
}

My regexp might be spotchy since I did it off the top of my head. Here is the complete syntax:

http://livedocs.adobe.com/flex/3/html/12_Using_Regular_Expressions_03.html


Best Regards,
~Aaron