gpt4 book ai didi

javascript - textContent 未读取所有文本

转载 作者:行者123 更新时间:2023-12-03 11:35:30 24 4
gpt4 key购买 nike

我的磁盘上有一个 xml 文件,其中包含:

<canvasTracking>
<!-- GoStats JavaScript Based Code -->
<script type="text/javascript" src="http://gostats.com/js/counter.js"></script>
<script type="text/javascript">_gos='monster.gostats.com';_goa=458628;
_got=5;_goi=1;_gol='Install live web stats on your site.';_GoStatsRun();</script>
<noscript><a target="_blank" title="Install live web stats on your site."
href="http://gostats.com"><img alt="Install live web stats on your site."
src="http://monster.gostats.com/bin/count/a_458628/t_5/i_1/counter.png"
style="border-width:0" /></a></noscript>
<!-- End GoStats JavaScript Based Code -->
</canvasTracking>

我用以下方式读取文件:

$.post('loadSave.php', {saveName : xml_name},       
function(xml) { // loaded data is in xml
canvas$ = $('#canvas');
if ($(xml).find("canvasTracking").length) {
canvasTracking = $(xml).find("canvasTracking")[0].textContent
}
else {
canvasTracking = '';
}

在读取后查看“xml”,我可以看到所有的 canvasTracking 文本都下来了,但是在读取之后

canvasTracking  =  $(xml).find("canvasTracking")[0].textContent

line,canvasTracking仅包含:

_gos='monster.gostats.com';_goa=458628;
_got=5;_goi=1;_gol='Install live web stats on your site.';_GoStatsRun();
<a target="_blank" title="Install live web stats on your site."
href="http://gostats.com"><img alt="Install live web stats on your site."
src="http://monster.gostats.com/bin/count/a_474698/t_5/i_1/counter.png"
style="border-width:0" /></a>

有人看到这个问题并知道我如何获取所有文本吗?

谢谢

最佳答案

尝试

var canvasTracking;
$.post('loadSave.php', {saveName : xml_name}
, function(xml) {
if (xml.firstChild.nodeName === "canvastracking") {
canvasTracking = $(xml.firstChild);
} else {
canvasTracking = ""
}
console.log(canvasTracking)
})

jsfiddle http://jsfiddle.net/guest271314/mm6yc1vh/

关于javascript - textContent 未读取所有文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26530545/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com