Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a large XML with the structure below. Now, I want to get rid of the <tuv xml:lang="en-GB"><seg>CONTENT</seg></tuv> nodes, so for each unit only the de-DE part stays (<tuv xml:lang="de-DE"><seg>CONTENT</seg></tuv>). Is there a way to do this with Notepad++ or a different tool? I am not really into coding, so the simpler the better.

What I have:

<tu tuid="ID_0">
<tuv xml:lang="en-GB">
<seg>Hello!</seg>
</tuv>
<tuv xml:lang="de-DE">
<seg>Hallo!</seg>
</tuv>
</tu>
<tu tuid="ID_1">
<tuv xml:lang="en-GB">
<seg>This is a test content! :)</seg>
</tuv>
<tuv xml:lang="de-DE">
<seg>Das ist ein Testinhalt! :)</seg>
</tuv>
</tu>
<tu tuid="ID_2">
<tuv xml:lang="en-GB">
<seg>All your base are belong tu us ...</seg>
</tuv>
<tuv xml:lang="de-DE">
<seg>Och nö, echt jetzt?</seg>
</tuv>
</tu>

What I want:

<tu tuid="ID_0">
<tuv xml:lang="de-DE">
<seg>Hallo!</seg>
</tuv>
</tu>
<tu tuid="ID_1">
<tuv xml:lang="de-DE">
<seg>Das ist ein Testinhalt! :)</seg>
</tuv>
</tu>
<tu tuid="ID_2">
<tuv xml:lang="de-DE">
<seg>Och nö, echt jetzt?</seg>
</tuv>
</tu>
share|improve this question
add comment

2 Answers

Ctrl+H (Replace...)

Find what: <tuv xml:lang="en-GB">.*?</tuv>

Search mode: Regular expression

checked: . matches newline

share|improve this answer
    
Thank you very much! –  Robert Herzog Aug 23 '12 at 8:19
add comment

In NotePad++ open the Replace dialog and specify:

Find what: <tuv xml:lang="en-GB">.*?</tuv>

Replace with:

Then set the Search Mode to 'Regular expression' and put a check in the '. matches newline' box.

Replace all should now remove all the en-GB blocks. Note: the trick here is with the ? following the *. It instructs the regex to be non-greedy.

share|improve this answer
    
Thank you, that helped tremendously! You are brilliant! –  Robert Herzog Aug 23 '12 at 8:18
    
Great. Thanks for the feedback! –  snowdude Aug 23 '12 at 8:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.