Create XML document on-fly with jQuery update document tree and get document XML as text

HTML

<button>First</button>
<button>Second</button>
<button>Third</button>

CSS

button {
     display: block;
     margin: 3px;
     color: red;
     width: 200px;
 }
 div {
     color: red;
     border: 2px solid blue;
     width: 200px;
     margin: 3px;
     text-align: center;
 }

JavaScript

$("button").click(function () {
     var v = $("<div>" + $(this).text() + "</div>");
     $(this).replaceWith(v);
     $(v).css('cursor', 'pointer');
     $(v).click(function () {
         alert('a');
     });
 });