com.gargoylesoftware.htmlunit.html
Class HTMLParser

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.html.HTMLParser

public final class HTMLParser
extends Object

SAX parser implementation that uses the NekoHTML HTMLConfiguration to parse HTML into a HtmlUnit-specific DOM (HU-DOM) tree.

Version:
$Revision: 9097 $
Author:
Christian Sell, David K. Taylor, Chris Erskine, Ahmed Ashour, Marc Guillemot, Ethan Glasser-Camp, Sudhan Moghe, Ronald Brill, Frank Danek

Field Summary
static String SVG_NAMESPACE
          SVG namespace.
static String XHTML_NAMESPACE
          XHTML namespace.
 
Method Summary
static ElementFactory getFactory(String tagName)
           
static void parseFragment(DomNode parent, DomNode context, String source)
          Parses the HTML content from the given string into an object tree representation.
static void parseFragment(DomNode parent, String source)
          Parses the HTML content from the given string into an object tree representation.
static HtmlPage parseHtml(WebResponse webResponse, WebWindow webWindow)
          Parses the HTML content from the specified WebResponse into an object tree representation.
static XHtmlPage parseXHtml(WebResponse webResponse, WebWindow webWindow)
          Parses the XHTML content from the specified WebResponse into an object tree representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XHTML_NAMESPACE

public static final String XHTML_NAMESPACE
XHTML namespace.

See Also:
Constant Field Values

SVG_NAMESPACE

public static final String SVG_NAMESPACE
SVG namespace.

See Also:
Constant Field Values
Method Detail

parseFragment

public static void parseFragment(DomNode parent,
                                 String source)
                          throws SAXException,
                                 IOException
Parses the HTML content from the given string into an object tree representation.

Parameters:
parent - the parent for the new nodes
source - the (X)HTML to be parsed
Throws:
SAXException - if a SAX error occurs
IOException - if an IO error occurs

parseFragment

public static void parseFragment(DomNode parent,
                                 DomNode context,
                                 String source)
                          throws SAXException,
                                 IOException
Parses the HTML content from the given string into an object tree representation.

Parameters:
parent - where the new parsed nodes will be added to
context - the context to build the fragment context stack
source - the (X)HTML to be parsed
Throws:
SAXException - if a SAX error occurs
IOException - if an IO error occurs

parseHtml

public static HtmlPage parseHtml(WebResponse webResponse,
                                 WebWindow webWindow)
                          throws IOException
Parses the HTML content from the specified WebResponse into an object tree representation.

Parameters:
webResponse - the response data
webWindow - the web window into which the page is to be loaded
Returns:
the page object which is the root of the DOM tree
Throws:
IOException - if there is an IO error

parseXHtml

public static XHtmlPage parseXHtml(WebResponse webResponse,
                                   WebWindow webWindow)
                            throws IOException
Parses the XHTML content from the specified WebResponse into an object tree representation.

Parameters:
webResponse - the response data
webWindow - the web window into which the page is to be loaded
Returns:
the page object which is the root of the DOM tree
Throws:
IOException - if there is an IO error

getFactory

public static ElementFactory getFactory(String tagName)
Parameters:
tagName - an HTML element tag name
Returns:
a factory for creating HtmlElements representing the given tag


Copyright © 2002–2014 Gargoyle Software Inc.. All rights reserved.