Hi there,
I have been trying this already many month ago, and just got back to it as I'm in need of reading out of an Html page! I have this Link I found maybe a couple of years ago and that code in there was the only item I could find which was doing something like that yet I never got it to work nor right now, and I tried for some time!
The original Link is: http://www.mikechambers.com/blog/200...a-data-source/
and my own code is this: Any help or any Ideas with this would be greatly appreciated! at this point in time the ERROR is with the HTMLControl which it can't relate too!
Code:
<mx:WindowedApplication
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
<![CDATA[
import mx.html.Object;
/* import flash.html.HTMLControl;*/
/* import mx.controls.HTML; */
private var htmlObject:HtmlControl = new HTMLControl();
private function onLoadAndParseClick():void {
/* htmlObject = new HTMLControl(); */
htmlObject.addEventListener(Event.COMPLETE, onHTMLLoadComplete);
htmlObject.load(new URLRequest("app-resource:/index.html"));
}
private function onHTMLLoadComplete(e:Event):void {
//get a reference to the top level html document
var document:Object = htmlObject.window.document;
/********** find number of links in html page ************/
//grab all of the links in the document
var a:Object = document.links;
//get the length
var len:int = a.length;
trace(len + " links in html page.");
/*********** Find element by ID and get its value ***********/
var foo:Object = document.getElementById("foo");
trace(foo.innerText);
/*********** Use the document DOM parsing API to parse out LI items **********/
//get all of the UL items
var lists:Object = document.getElementsByTagName("ul");
//make sure we found some
if(lists.length > 0)
{
//grab the first one
var ul:Object = lists[0];
//get the child nodes
var childNodes:Object = ul.childNodes;
var childLen:int = childNodes.length;
var tempNode:Object;
//loop through the nodes looking for LI elements
for(var j:int = 0; j < childLen; j++)
{
tempNode = childNodes[j];
if(String(tempNode.nodeName).toLowerCase() == "li")
{
//print the value of the LI element
trace("LI Found : " + tempNode.innerHTML);
}
}
}
}
]]>
</mx:Script>
<mx:Button label="Load and Parse" right="10" bottom="10" click="onLoadAndParseClick()"/>
</mx:WindowedApplication>