JSFiddle - React, Tailwind, and code Playground
HTML
<div id="result"></div>
JavaScript
$(document).ready(function(){
var xmlstr = '<test><val attr="<popo" /></test>';
var xmldoc = $(xmlstr);
xmldoc.find('val').attr('pilou', '<toto>&');
$("#result").text(xmldoc.html());
});