2010-10-04 48 views
0

问候,jquery从外部文件中删除标签并保存它们

我需要删除XML文件中的标签(大约1000)。我试过用jQuery,但没有成功:

<html> 
<!--jquery app removes specific <t2_patch ...>-tag --> 
<script src="http://code.jquery.com/jquery-latest.min.js"></script> 
</head> 
<body> 

<button>Kill t2_patch-tags </button> 
<script> 
     $("button").click(function() { 
    $('/home/dan/series14AreaListOnly.xml').remove('t2_patch'); 
}); 
</script> 
</body> 
</html> 

我的目标是删除300MB大型XML文件中的t_patch标签。这种做法到目前为止还没有确定,还是我完全错了。我如何保存更改? (因为remove()函数实际上不会直接在xml文件上删除任何内容?)。

预先感谢任何提示与问候

丹尼亚尔

回答

0

最好的办法是建立一个后端PHP脚本和ping到它删除的内容实体,并等待回调,速度更快,可靠,不太可行,因为如果有人这样做:

$('/home/dan/series14AreaListOnly.xml').remove('*'); 
0

为什么不XSLT?而且,在XML中删除标签的含义是什么?

如果你的意思是剥离的元素,这个样式表删除输入任何t2_patch元素:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:template match="node()|@*"> 
     <xsl:copy> 
      <xsl:apply-templates select="node()|@*"/> 
     </xsl:copy> 
    </xsl:template> 
    <xsl:template match="t2_patch"/> 
</xsl:stylesheet> 

如果你的意思是剥离的元素,但保持它的内容,这个样式表:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:template match="node()|@*"> 
     <xsl:copy> 
      <xsl:apply-templates select="node()|@*"/> 
     </xsl:copy> 
    </xsl:template> 
    <xsl:template match="t2_patch"> 
     <xsl:apply-templates select="node()"/> 
    </xsl:template> 
</xsl:stylesheet> 

注意:覆盖身份规则。

相关问题