<s1 title="HTML Parsing">

<p>Resin includes an HTML parser.  Parsing HTML is convenient:</p>
<ul>
<li>Parse documents created by HTML editors.
<li>Parse documents on the web.
<li>Provide a HTML interface for web designers.
</ul>

<p>Parsing HTML is like using the JAXP interface, except you'll be using
Resin's API.</p>

<p>Because printing HTML uses different rules from XML, e.g. &lt;img> has
no end tag, you'll need to use <var/printHtml/> instead of
just <var/print/>.</p>

<example title="Parsing HTML">
import java.io.*;
import org.w3c.dom.*;
import com.caucho.xml.*;

...

Html parser = new HtmlParser();

// Parse the file into a DOM Document (org.w3c.dom)
Document doc = parser.parse("test.html");

// Create a new HTML printer (com.caucho.xml)
FileOutputStream os = new FileOutputStream("out.xml");
XmlPrinter printer = new XmlPrinter(os);

// Print the document using HTML rules
printer.printHtml(doc);
os.close();
</example>

<p>You can also take advantage of Resin's VFS API and parse documents
directly from the web:</p>

<example title="Parsing HTML">
import java.io.*;
import org.w3c.dom.*;
import com.caucho.xml.*;

...

Html parser = new HtmlParser();

Path yahoo = Vfs.lookup("http://www.yahoo.com");

// Parse the file into a DOM Document (org.w3c.dom)
Document doc = parser.parse(yahoo);
</example>
</s1>

