&#and;是用於十六進制字符的html解析器轉義符。因此,您需要做的是剝離它們並將剩餘的'15E'值傳遞給此(例如):
<!DOCTYPE html>
<div id="myId">
yo oyyoyoyooy &amp;amp;#xAA;suuupspuspupsu
ssdosudoisduoisudoiud
&amp;#xFE;
</div>
<script>
document.addEventListener("DOMContentLoaded", function(){
var nodeIterator = document.createNodeIterator(
// Node to use as root
document.getElementById('myId'),
// Only consider nodes that are text nodes (nodeType 3)
NodeFilter.SHOW_TEXT,
// Object containing the function to use for the acceptNode method
// of the NodeFilter
{ acceptNode: function(node) {
// Logic to determine whether to accept, reject or skip node
// In this case, only accept nodes that have content
// other than whitespace
if (/&.*?#x[^;]+;/ig.test(node.data)) {
return NodeFilter.FILTER_ACCEPT;
}
}
},
false
);
// Show the content of every non-empty text node that is a child of root
var node;
while ((node = nodeIterator.nextNode())) {
node.nodeValue = node.nodeValue.replace(/&.*?#x([^;]+);/ig, function(match, p1) {
return String.fromCharCode(parseInt(p1, 16))
});
}
});
</script>
請向我們展示XML輸入和XML中的'value'屬性值輸入。 –
來自服務器的響應是:'TECHNO A. & amp;#x15E; .' – kamaci