简体   繁体   English

使用Python和Notepad ++更改XML文件中包含的文本?

[英]Change text contained in an XML file using Python and Notepad++?

I have an existing XML file: https://gist.github.com/anonymous/8182569 我有一个现有的XML文件: https : //gist.github.com/anonymous/8182569

I want to change all the text values of line2, line4, line7,line18,etc..by custom text like that: 我想通过这样的自定义文本来更改line2,line4,line7,line18等的所有文本值:

1:Text1
2:Text2
3:Text3
4:Text4
etc..

What would be the easiest way to do that? 最简单的方法是什么?

It seems to me that the procedure requested is not meant to be done programmatically but the OP is just looking for a workaround to avoid replacing a lot of lines - it may be tedious. 在我看来,所请求的过程并不是要以编程方式完成,但是OP只是在寻找一种解决方法,以避免替换很多行-这可能很乏味。

A part from developing a complex python script using lxml for instance, you may use another editor like sublime text ( http://www.sublimetext.com/ ) and its multiple cursor capability: 例如,使用lxml开发复杂的python脚本的一部分,您可以使用其他编辑器,例如sublime text( http://www.sublimetext.com/ )及其多光标功能:

select the lines you want to replace, press ctrl+shift+l and paste the multiple lines. 选择要替换的行,按ctrl+shift+l并粘贴多行。

However, if you want to mimic this approach on Notepad++ please check this answer 但是,如果您想在Notepad ++上模仿此方法,请检查此答案

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

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