Thread: [Htmlparser-user] Tags look up
Brought to you by:
derrickoswald
From: Dipesh S. <dip...@re...> - 2007-04-20 02:30:29
|
aW1wb3J0IG9yZy5odG1scGFyc2VyLlBhcnNlcjsNCiAgICBpbXBvcnQgb3JnLmh0bWxwYXJz ZXIudXRpbC5Ob2RlTGlzdDsNCiAgICAgaW1wb3J0IG9yZy5odG1scGFyc2VyLnV0aWwuUGFy c2VyRXhjZXB0aW9uOw0KICAgICBpbXBvcnQgb3JnLmh0bWxwYXJzZXIuYmVhbnMuU3RyaW5n QmVhbjsNCiAgICBpbXBvcnQgb3JnLmh0bWxwYXJzZXIuZmlsdGVycy5UYWdOYW1lRmlsdGVy Ow0KICAJaW1wb3J0IG9yZy5odG1scGFyc2VyLnV0aWwuKjsNCiAgCWltcG9ydCAJb3JnLmh0 bWxwYXJzZXIuKjsNCiAgCWltcG9ydCBvcmcuaHRtbHBhcnNlci5maWx0ZXJzLkFuZEZpbHRl cjsNCiAgCWltcG9ydCBvcmcuaHRtbHBhcnNlci5maWx0ZXJzLkhhc1BhcmVudEZpbHRlcjsN Cg0KDQogICAgY2xhc3MgVGVzdA0KICAgIHsNCiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lk IG1haW4gKFN0cmluZ1tdIGFyZ3MpDQogICAgICAgIHsNCiAgICAgICAgICAgIHRyeQ0KICAg ICAgICAgICAgew0KICAgICAgICAgICAgCQ0KICAgICAgICAgICAgCVBhcnNlciBwYXJzZXIx ID0gbmV3IFBhcnNlciAoImh0dHA6Ly93d3cuZGVhbHMyYnV5LmNvbSIpOw0KICAgICAgICAg ICAgCVBhcnNlciBwYXJzZXIyID0gbmV3IFBhcnNlciAoImh0dHA6Ly93d3cuZGVhbHMuY29t Iik7DQoNCg0KICAgICAgICAgICAgCU5vZGVJdGVyYXRvciBlMSA9IHBhcnNlcjEuZWxlbWVu dHMgKCk7DQogICAgICAgICAgICAJTm9kZUl0ZXJhdG9yIGUyID0gcGFyc2VyMi5lbGVtZW50 cyAoKTsNCiAgICAgICAgICAgIAkNCiAgICAgICAgICAgIAkNCiAgICAgICAgICAgIAkNCiAg ICAgICAgICAgIAl3aGlsZShlMS5oYXNNb3JlTm9kZXMoKSAmJiBlMi5oYXNNb3JlTm9kZXMo KSkNCiAgICAgICAgICAgIAkNCiAgICAgICAgICAgIAl7DQogICAgICAgICAgIAkJaWYgKGUx Lm5leHROb2RlKCk9PWUyLm5leHROb2RlKCkpDQogICAgICAgICAgIAkJCVN5c3RlbS5vdXQu cHJpbnRsbiAoIlllcyIpOw0KICAgICAgICAgICAgCQllbHNlDQogICAgICAgICAgICAJCQlT eXN0ZW0ub3V0LnByaW50bG4gKCJObyIpOw0KICAgICAgICAgICAJCSAgICAgICAgCQkNCiAg ICAgICAgICAgIAkNCiAgICAgICAgICAgIAl9DQogICAgICAgICAgDQogICAgICAgICAgICAJ IA0KDQogICAgICAgICAgICAJIA0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgY2F0Y2gg KFBhcnNlckV4Y2VwdGlvbiBwZSkNCiAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICBw ZS5wcmludFN0YWNrVHJhY2UgKCk7DQogICAgICAgICAgICB9DQogICAgICAgIH0NCiAgICB9 DQo= |
From: Gaurav P. <gau...@gm...> - 2007-04-20 04:17:48
|
Hi, Try using the below stated code.This is basically ment for moving through the web-page node by node . So if u want to compare the nodes then try using this for both the urls. import org.htmlparser.Parser; import org.htmlparser.Tag; import org.htmlparser.Text; import org.htmlparser.util.ParserException; import org.htmlparser.visitors.NodeVisitor; public class MyVisitor extends NodeVisitor { public MyVisitor () { } public void visitTag (Tag tag) { System.out.println ("\n" + tag.getTagName () + tag.getStartPosition ()); } public void visitStringNode (Text string) { System.out.println (string); } public static void main (String[] args) throws ParserException { Parser parser = new Parser ("http://cbc.ca"); Visitor visitor = new MyVisitor (); parser.visitAllNodesWith (visitor); } On 20 Apr 2007 02:30:14 -0000, Dipesh Sharma <dip...@re...> wrote: > > Hi I'm trying to compare the html tag nodes of 2 different web pages by > taking one node at a time. Hence, I need to compare the 1st node of the 2 > web pages, then go to 2nd nodes and compare and so on. Could you plz help me > how i can achieve this. I''v tried to use Node iterator but haven't been > successfull. Attached is my code. > > > > > > > > [image: banner2]<http://adworks.rediff.com/cgi-bin/AdWorks/click.cgi/www.rediff.com/signature-home.htm/1050715198@Middle5/1165462_1159560/1164629/1?PARTNER=3&OAS_QUERY=null+target=new+> > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > > > |
From: sebb <se...@gm...> - 2007-04-20 11:23:30
|
On 20 Apr 2007 02:30:14 -0000, Dipesh Sharma <dip...@re...> wrote: > > > Hi I'm trying to compare the html tag nodes of 2 different web pages by taking one node at a time. Hence, I need to compare the 1st node of the 2 web pages, then go to 2nd nodes and compare and so on. Could you plz help me how i can achieve this. I''v tried to use Node iterator but haven't been successfull. Attached is my code. > > The node comparison: if (e1.nextNode()==e2.nextNode()) will always be false, as that will only be true if they are identical Objects. You need to compare the relevant attributes of the node objects instead. I've not looked at the API, but perhaps that defines an equals() method that will work for you. If not, you will need to write your own comparison method. |