删除 XML 中的指定标签 (notepad++) [英] Remove specified tags in XML (notepad++)

查看:126
本文介绍了删除 XML 中的指定标签 (notepad++)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 gps 轨道有一个(非常)大的 XML 文件.它是这样构建的:

I have a (very) big XML file for my gps track. It's built like this:

<trkpt lat="45.4818095" lon="3.76271898">
        <time>2010-08-29T17:20:52Z</time>
    </trkpt>
    <trkpt lat="45.48068593" lon="3.762722181">
        <time>2010-08-29T17:21:37Z</time>
    </trkpt>
    <trkpt lat="45.47923258" lon="3.762515148">
        <time>2010-08-29T17:22:35Z</time>
    </trkpt>

我想分享我的 GPS 轨迹,但是 之间的所有信息都没有用.有没有办法在notepad++中删除这些标签?

I want to share my GPS track, but all the information between the <time> and </time> is useless. Is there a way to delete these tags in notepad++?

推荐答案

你总是可以进行查找和替换:

You could always do a find and replace:

find 并替换为空白(确保选中正则表达式)

find <time>[0-9A-Z:-]*</time> and replace with blank (make sure Regular Expressions is checked)

快速说明,这将替换文本文件中以 <time> 开头的所有内容,并包含任意数量的字母数字字符、冒号 (:) 或破折号,后跟 </时间>标签.如果您想删除标签前的空格,您可以使用以下代码:

Quick clarification, this replaces everything in the text file that start with <time> and has any amount of alphanumeric characters, colons (:) or dashes followed by a </time> tag. If you want to remove the spaces before the tag you can use the following instead:

find [\t ]* 替换为空白.

find [\t ]*<time>[0-9A-Z:-]*</time> replace with blank.

如果您想通过这样做删除剩余的空行,您可以使用大多数 Notepad++ 版本中包含的 TextFX 插件:

If you want to remove the empty lines left over by doing this, you can use the TextFX plugin included with most versions of Notepad++:

TextFX -> TextFx 编辑 -> 删除空行

TextFX -> TextFx Edit -> Delete Blank Lines

或者只是切换到扩展查找和搜索 \n\r

Or just switch to extended find and search for \n\r

这篇关于删除 XML 中的指定标签 (notepad++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆