Hello,
Is there an example on how to parse multiple tags from one page?
Currently i do a
Parser parser = new Parser(filename);
Node Nodes [] = parser.extractAllNodesThatAre(BodyTag.class);
i also want to do
Node NodesTitle [] = parser.extractAllNodesThatAre(TitleTag.class);
Do i have to create a new parser?
How is the best way to do this
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can either reset() the parser and filter it all again, or use a dual purpose filter that accepts both types of nodes.
If you look at the code behind extractAllNodesThatAre() it is using a NodeClassFilter:
extractAllNodesThatMatch (new NodeClassFilter (<cls>));
so you could get both types of nodes (assuming your program logic could handle it) with:
extractAllNodesThatMatch (
new OrFilter (
new NodeClassFilter (<cls1>),
new NodeClassFilter (<cls2>)));
whichm because of the 'OR' permits both classes to pass.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
Is there an example on how to parse multiple tags from one page?
Currently i do a
Parser parser = new Parser(filename);
Node Nodes [] = parser.extractAllNodesThatAre(BodyTag.class);
i also want to do
Node NodesTitle [] = parser.extractAllNodesThatAre(TitleTag.class);
Do i have to create a new parser?
How is the best way to do this
Thanks
You can either reset() the parser and filter it all again, or use a dual purpose filter that accepts both types of nodes.
If you look at the code behind extractAllNodesThatAre() it is using a NodeClassFilter:
extractAllNodesThatMatch (new NodeClassFilter (<cls>));
so you could get both types of nodes (assuming your program logic could handle it) with:
extractAllNodesThatMatch (
new OrFilter (
new NodeClassFilter (<cls1>),
new NodeClassFilter (<cls2>)));
whichm because of the 'OR' permits both classes to pass.