jQuery のおかげで XHTML ページ (コンピューターに保存されている) の URL を取得し、このページを解析してから XML の項目を削除したいと考えています。
私の XHTML ページ
<html>
...
<exampleXML>
<dataset>a</dataset>
<dataset>b</dataset>
<dataset>c</dataset>
</exampleXML>
...
</html>
私のjQueryコード
var url_val = $("#xhtml_page").val();
$.get(url_val, function(data) {
$(data).find("dataset").each(function() {
if ($(this).text() == "a"){
$(this).remove();
}
});
$("#body-tmpl").html('<div id="id_container"></div>');
$("#id_container").html($(data));
});
そして、アイテムが削除されたら、新しい XHTML のコンテンツを div で送信します。
しかし、残念ながら、XHTML 要素 (例 a) を削除して、新しいページを div に配置することはできません。それは最善の解決策ですか?
アイテムを削除する前に、XHTML を iframe に配置しました。
<iframe frameborder="0" style="width:100%; height:100%;" src="XHTMLfile.html">
#document<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-strict.dtd"><html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head> … </head>
<body style="overflow: hidden; margin: 0px; font: 11px sans-serif; cursor: auto;">
<img id="hiddenImage" style="display:none" src="http://soft.sourceforge.net /img/hidden.png"></img>
<img id="loadingImage" style="display:none" src="http://soft.sourceforge.net /img/loading.gif"></img>
<img id="logo" style="display:none" src="http://soft.sourceforge.net/img/logo.png"> </img>
<noscript> … </noscript>
<div style="display:none"> … </div><div style="position: absolute; top: 1%; right: 2%; text-align: right;"> … </div>
<input type="button" value="x" style="position: fixed; visibility: visible; right: 10.5px; top: 492.333px;"></input>
<canvas width="1000" height="700"></canvas>
<div style="position: absolute; top: 0px;"> … </div>
</body>
</html>
</iframe>
今、私はそれを div に入れたときにそれを持っています:
<div id="id_container" style="width:1000px; height:700px;">
<meta charset="utf-8">
</meta><link href="http://soft.sourceforge.net/img/favicon.ico" rel="shortcut icon">
</link><img id="hiddenImage" style="display:none" src="http://soft.sourceforge.net/img/hidden.png"></img>
<img id="loadingImage" style="display:none" src="http://soft.sourceforge.net/img/loading.gif"></img>
<img id="logo" style="display:none" src="http://soft.sourceforge.net/img/logo.png"></img>
<noscript> … </noscript>
<div style="display:none">
… </div>
</div>