Menu

#48 How could I remove a node

closed
5
2007-05-24
2006-10-25
virtu
No

After parse a html, how could I remove a node?

like thease code,

<html>
<head>
<title>test</title>
</head>
<body>
this is a test.
</body>

How could I remove <head> ... </head>

Thank you very mush!

Discussion

  • Derrick Oswald

    Derrick Oswald - 2007-04-23
    • assigned_to: nobody --> derrickoswald
    • status: open --> pending
     
  • Derrick Oswald

    Derrick Oswald - 2007-04-23

    Logged In: YES
    user_id=605407
    Originator: NO

    You can delete the node from the parent's children and then convert the page back to HTML.
    The pseudo code is:

    // get the entire page
    NodeList list = parser.parse (null);

    // find the node to be deleted
    NodeList doomed = list.extractAllNodesThatMatch (some_filter);

    // remove these nodes from their parent
    foreach (Node node in doomed)
    {
    Node parent = node.getParent ();
    parent.getChildren ().remove (node);
    }

    // reprint the HTML
    System.out.println (list.toHtml ());

     
  • SourceForge Robot

    • status: pending --> closed
     
  • SourceForge Robot

    Logged In: YES
    user_id=1312539
    Originator: NO

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 30 days (the time period specified by
    the administrator of this Tracker).

     

Log in to post a comment.