简体   繁体   English

删除XML中的指定标记(记事本++)

[英]Remove specified tags in XML (notepad++)

I have a (very) big XML file for my gps track. 我的gps轨道有一个(非常)大的XML文件。 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>

I want to share my GPS track, but all the information between the <time> and </time> is useless. 我想分享我的GPS轨道,但<time></time>之间的所有信息都是无用的。 Is there a way to delete these tags in notepad++? 有没有办法在notepad ++中删除这些标签?

Used <time>.*?</time> and it worked perfectly. 使用<time>.*?</time> ,它完美无缺。

在此输入图像描述

You could always do a find and replace: 您可以随时进行查找和替换:

find <time>[0-9A-Z:-]*</time> and replace with blank (make sure Regular Expressions is checked) 找到<time>[0-9A-Z:-]*</time>并替换为空白(确保选中正则表达式)


EDIT: 编辑:

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. 快速说明,这将替换文本文件中以<time>开头的所有内容,并且包含任意数量的字母数字字符,冒号(:)或短划线,后跟</time>标记。 If you want to remove the spaces before the tag you can use the following instead: 如果要删除标记之前的空格,可以使用以下代码:

find [\\t ]*<time>[0-9A-Z:-]*</time> replace with blank. 找到[\\t ]*<time>[0-9A-Z:-]*</time>替换为空白。

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++: 如果要通过执行此操作删除遗留的空行,可以使用大多数版本的Notepad ++附带的TextFX插件:

TextFX -> TextFx Edit -> Delete Blank Lines TextFX - > TextFx编辑 - >删除空行

Or just switch to extended find and search for \\n\\r 或者只需切换到扩展查找并搜索\\n\\r

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM