Remove specified tags in XML (notepad++)

三世轮回 提交于 2019-12-14 04:16:11

问题


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>

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++?


回答1:


You could always do a find and replace:

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


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. 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.

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 Edit -> Delete Blank Lines

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




回答2:


Used <time>.*?</time> and it worked perfectly.



来源:https://stackoverflow.com/questions/16717938/remove-specified-tags-in-xml-notepad

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!