This code is an improvement from your original version. However, you still have the 'empty string' bug, wherein an empty string passed as an attribute will instead result in the attribute having no value, which is another thing entirely.
<input value="" /> <-- Valid
<input value /> <-- Invalid
In fact, as I recall, according to XHTML standards, no
attribute should be valueless. My version of your code substitutes the attribute name if no value is supplied.
<td nowrap> <-- OK, but invalid XHTML
<td nowrap="nowrap"> <-- Valid XHTML, and still read properly by older browsers
Also, I must reiterate that allowing use of the double-quote character would greatly reduce your code's current size. There is no practical use of this code that requires its employment in a link.