删除一对 XML 标签
有没有一种快速直观的方法来删除不需要的 XML 标签。必须删除开始和结束标记非常耗时。我有一些 XML 代码,需要清除导致错误的冗余节点。我的问题与 HTML 中的此内容非常相似:
从:
<b><b>double bolded</b></b>
到此:
<b>double bolded</b>
我尝试找到可以在 Notepad++ 中执行此操作的东西,但找不到任何东西。我发现一些脚本可能会执行类似的操作,但重要的是我可以手动控制它,因为有时我的代码中需要双重嵌套。
编辑:
这是一个 XML 示例,我将手动对其进行格式化:(
<displayFormula>
<mrow>
<mrow>
<mo>=</mo>
<mrow>
<mi mvar="S">{Selling Price}</mi>
<mo>×</mo>
<mi mvar="x">{hypo quant}</mi>
</mrow>
</mrow>
</mrow>
</displayFormula>
<displayFormula>
上面的示例使用 MathML)
的多个嵌套是多余的,会在解析时导致错误。有时您会希望
在一起,尽管就像在这种结构中一样:
<displayFormula>
<mrow>
<mrow>
<mi mvar="S">{Selling Price}</mi>
<mo>×</mo>
<mi mvar="x">{hypo quant}</mi>
</mrow>
<mrow>
<mi mvar="S">{Selling Price}</mi>
<mo>×</mo>
<mi mvar="x">{hypo quant}</mi>
</mrow>
</mrow>
</displayFormula>
我注意到 Notepad++ 在选择一个标签时会自动突出显示打开和关闭标签,我只是想知道是否有一个删除那些突出显示的标签的方法。
Is there a fast visual way of deleting unwanted XML tags. It's just very time consuming having to delete both the beginning and the end tag. I have some XML code which I need to clean up for redundant nodes which are causing an error. My issue is very synonymous with having this in HTML:
From:
<b><b>double bolded</b></b>
to this:
<b>double bolded</b>
I tried finding something that could do this in Notepad++ but couldn't find anything. I found some scripts that might do something similar, but it's important that I can control it manually because there are times where a double nesting is required in my code.
EDIT:
Here's a sample piece of XML which I would be formatting manually:
<displayFormula>
<mrow>
<mrow>
<mo>=</mo>
<mrow>
<mi mvar="S">{Selling Price}</mi>
<mo>×</mo>
<mi mvar="x">{hypo quant}</mi>
</mrow>
</mrow>
</mrow>
</displayFormula>
<displayFormula>
(The above sample uses MathML)
The multiple nests of <mrow>
are redundant and cause errors while parsing. There are times where you would want <mrow>
together though like in this structure:
<displayFormula>
<mrow>
<mrow>
<mi mvar="S">{Selling Price}</mi>
<mo>×</mo>
<mi mvar="x">{hypo quant}</mi>
</mrow>
<mrow>
<mi mvar="S">{Selling Price}</mi>
<mo>×</mo>
<mi mvar="x">{hypo quant}</mi>
</mrow>
</mrow>
</displayFormula>
I noticed that Notepad++ automatically highlights both the open and close tags when one is selected and I was just wondering if there was a way to delete those highlighted tags.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来非常适合一些正则表达式。以下内容应该适用于 HTML 示例中的简单标记,但需要一些工作才能使其适用于包含属性的更复杂的标记。
搜索:
替换:
Sounds ideal for a little regex. The following should work for simple tags like in your HTML example but will need some work to make it work for more complex mark-up that contains attributes for example.
Search:
Replace:
您可以使用 TopStyle。 http://www.topstyle4.com/
它有一个功能,可以让您
查找< /code> 然后
根据提示替换
,这样它将找到所有实例,然后遍历每个实例以查看您是否想要或不想替换它(使用某些内容或空格 [什么都没有])You could use TopStyle. http://www.topstyle4.com/
It has a feature that allows you to
find
and thenreplace on prompt
, so it will find all the instances and then go through each one to see if you do or do not want to replace it (either with something or a blank space [nothing])