Re: [Htmlparser-user] No previous sibling
Brought to you by:
derrickoswald
From: Derrick O. <der...@ro...> - 2007-07-11 15:28:09
|
Cinza, If you have the complete list of nodes in a node list and are using this to filter, you can find your node just by stepping through the list. So let's say your list is all_nodes, and your table filter code is something like this: NodeList tables = all_nodes.ExtractAllNodesThatMatch (new MyTableFilter ()); then you can step through the nodes in all_nodes until you reach the table, and the prior node is the one you want: Node previous = null; Node target = tables.elementAt(0); // or cycle through the results for (int i = 0; i < all_node.Size(); i++) { Node candidate = all_nodes.elementAt(i); if (candidate == target) break; else previous = candidate; } Here, previous is set to the node before your table if it's not null. Derrick ----- Original Message ---- From: "c....@ar..." <c....@ar...> To: htm...@li... Sent: Wednesday, July 11, 2007 10:53:23 AM Subject: [Htmlparser-user] No previous sibling Thanks Derrick! It worked! But now I have another question. I think that if my node doesn't have a parent node, the previousSibling and nextSibling methods do not work. Is it right? This is my problem: as I said I have no html, head and body tag. I have some table tags but I need to access to the previous row (or node) just before the table. I filtered the page with the TagNameFilter("table"), but I do not have any parent node. What can I do? Thanks again! Cinzia ------------------------------------------------------------------------- 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 |