删除 XML 中的指定标签 (notepad++)

编程入门 行业动态 更新时间:2024-10-28 04:15:33
本文介绍了删除 XML 中的指定标签 (notepad++)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我的 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屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 10:37:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1408773.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标签   XML   notepad

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!