Question: How do I handle closing tags (ex: `</h1>`) with the Java HTML Parser Library?

For example, if I have the following:

```
public class MyFilter implements NodeFilter {

 public boolean accept(Node node) {
  if (node instanceof TagNode) {
   TagNode theNode = (TagNode) node;
   if (theNode.getRawTagName().equals("h1")) {
    return true;
   } else {
    return false;
   }
  }
  return false;
 }
}

public class MyParser {
 public final String parseString(String input) {
  Parser parser = new Parser();
  MyFilter theFilter = new MyFilter();
  parser.setInputHTML("<h1>Welcome, User</h1>");
  NodeList theList = parser.parse(theFilter);
  return theList.toHtml();
 }
}

```

When I run my parser, I get the following output back:

```
<h1>Welcome, User</h1>Welcome, User</h1>

```

The NodeList contains a list of size 3 with the following entities:

```
(tagNode) <h1>

(textNode) Welcome, User

(tagNode) </h1>

```

I would like the output to be "`<h1>Welcome, User</h1>`". Does anyone see what is wrong in my sample parser?

Answer: 
Just don't write this method :)

Any time some business logic needs to update specific fields on a person, *update the specific fields on that person* (and remember to update the datacontext before the http context is unloaded)

You were on the right track when you said "Is that redundant since L2S already mapped my Person Table to a Class?". Just use the class that L2S has provided :)

If you've got a (winforms) screen that needs to edit this 30 field person object, then the easiest thing to do is to [databind](http://msdn.microsoft.com/en-us/library/ef2xyb33(v=VS.100).aspx) the fields on your screen directly to the fields on linq to sql's Person object. Here's a typical screen's lifecycle:

* Your form is constructed (with a person ID)
* Your form's load event handler will retrieve a Person object from Linq to Sql: `context.tblPersons.Single(x=>x.ID == personID)`
* This Person will be set as the form's main [BindingSource's](http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.aspx) DataSource
* A whole lot of textboxes on the screen will be setup to bind to each field on that person object, allowing the user to edit the properties directly (you can just drag a detailsview from the data sources tab onto your form in VS to do these automatically)
* When the user hits save, just call EndEdit on the DataSource, then SubmitChanges on the L2s Datacontext

All going well, you should see new values in your database...
What is wrong with your Update method is that you have are creating a datacontext instance within it.

And I presume you also have other CRUD methods which do the same.

If you abstract your CRUD operations to a Repository class you will be using the DataContext as it was meant to be used.

See the answer to this [question](https://stackoverflow.com/questions/2473795/linq-to-sql-add-update-in-different-methods-with-different-datacontexts), if you follow the design outlined you will be just passing a Person object to the repository Update method and it will not be so unwieldy.