Tom De Witte
Tom De Witte

Reputation: 163

Remove specified tags in XML (notepad++)

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

Upvotes: 13

Views: 51150

Answers (2)

spicet
spicet

Reputation: 561

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

enter image description here

Upvotes: 15

Lawrence Andrews
Lawrence Andrews

Reputation: 440

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

Upvotes: 10

Related Questions