I'm having an issue with some XML when processing it with my Javascript, because the Node modules (libxslt & libxmljs) don't know how to handle a self closing tag. Through some different testing I have narrowed the problem down to XML elements that self close, like the center element in the example below:
var string =
"<head>
<body>
<example />
</body>
</head>"
Simply put, I need a way of removing
<example />
entirely; without knowing the position prior, because there are multiple in a document, and without addressing the tag name directly, because the self closing tags vary from document to document.
If .replace() obtains the location ID of the parameter, it could be used with a function as the second parameter. Something like this:
string.replace('/>', function(match){
//search from match back for the closest '<' and remove that substring.
})