Mi presentación en la FLISOL - El Alto - Bolivia, 2010
Hola Amigos acá comparto la presentación que hice el sábado (de Abril) pasado con motivo de la FLISOL en la ciudad de El Alto - Bolivia, 2010.
Hola Amigos acá comparto la presentación que hice el sábado (de Abril) pasado con motivo de la FLISOL en la ciudad de El Alto - Bolivia, 2010.
La Comunidad Bolivia Webprende quiere conocer las áreas donde se puede fortalecer la Web 2.0 en Bolivia.
Llenando este formulario ayudaras a encaminar a la comunidad. ![]()
[polldaddy poll="1368149"]
I was looking for an HTML Parser that parses XHTML. I tested many parser like: TagSoup, Apache Sax, Jericho Parser, etc… But i had the following problems:
So, I found HTML Parser. This one was very easy to use. Here is an example: Let’s have some html called test.html like this:
<html>
<head></head>
<body>
<img>
<h1>Hello World</h1>
</body>
</html>
You want to get the tag <h1> that has “Hello Word”, note that the tag <img> is incomplete. Let’s code.
Parser parser = new Parser("test.html");
NodeList list = parser.parse(new HasChildFilter(new StringFilter("Hello World")));
System.out.println("tag founded = " + list.elementAt(0).toHtml());
The previous code finds the tag <h1> and prints:
tag founded = <h1>Hello World</h1>
Here is the explanation:
Parser class, this class is in charge to load the html file.
parser.parse(), is the method that get all nodes or filter the nodes you want to use.
HasChildFilter and StringFilter, are in charge to filter the nodes. In the example we are looking all tags that has children with the text ‘Hello Word’.
These filters, saved me a lot of work, Html Parser has other filters too.
Well this is it for now :).
Recent Comments