AS3 HTML Parser Library:

This project is an AS3 HTML parser and renderer to replace the simple htmlString support in some elements. Compatible with Flex 3, written using the MPL version of the Flex 3 SDK. The parser is simple and expects limited HTML errors. The renderer mocks the presentation of Firefox 3 but allows for each element type's rendering to be overridden. The project is self-contained (requires nothing but the Flex 3 SDK to compile). It currently supports most elements (including img, span, div) and is approximately 70% accurate with more changes to come.

The project is offered free under the BSD license though donations are encouraged.

This project is intended for SWF web applications. People building AIR applications can use this project or the built-in HTML facilities.

Why this project over others?
1. This project contains an HTML parser:
  Other projects rely on AS3 XML parsing facilities which works for XHTML but won't work for code such as (because the img tag is not closed according to XML parsers):
    <div><img src="test.jpg"><input type=checkbox checked></div>
  This also means this project can accept HTML output directly for WYSIWYG editors such as FCK or tinyMCE. In fact, the project was built around this use case.
2. This project uses 100% flash:
  Other projects require browser interaction (either Javascript or IFrames). This project renders the HTML using entirely AS3 objects and will work even if using allowScriptAccess=never (as is forced by sites like Facebook).
3. The license:
  This project is offered 100% free for all uses. Simply maintain the authorship messages in each file.
4. Compact:
  This project only adds ~30KB to a compiled SWF file.

  Parsing: Simple html fragments (about 10 elements) parses in ~6ms. Larger HTML fragments (containing 100 or more elements) parses in ~50ms.
  Rendering: Simple html fragments (about 10 elements) renders in ~60ms. Larger HTML fragments (containing 100 or more elements) parses in ~250ms.


Sample Usage (see TestApp's main.mxml here for more information):
  import mx.core.UIComponent;
  import org.groe.html.*;
  var e:Element = HtmlParser.parse(htmlString);
  var o:UIComponent = FlashHtmlRenderer.render(e);
  if (o == null)
  {"Unable to render html");
  //Assume container is an element on the page

Project Page




Using this project or looking for new features? Support this Project with a small donation:
Support This Project