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: 
A `DataContext` follows a pattern known as a Unit of Work. It tracks all inserts, updates, and deletes you do during a piece of code.

Once that piece of code is done running, the `SubmitChanges` method sends all modifications to the database *at one time*. There is no need for you to do anything; changes you make will automatically be persisted.
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.