Could you explain in more detail your exact requirements? why are you trying to substitute "
app", etc...? Are you really trying to run the substitution on the whole section?
sed is not a very good multi-line editor, and only operates on one line at a time by default. Targeting multi-line blocks often requires complex handling.
What we really need to know is, what defines the line that needs to be changed?
If it's the content of the tag, for example, you may really only need something like this:
Code:
sed '\|test2| s|jjj|data|g' file
Or if you need it to be more accurate, and specifically target the tag itself, perhaps this:
Code:
sed -r '\|test2| s|<(/?)[^>]+>|<\1data>|g' file
But if you need it to match something only within a certain sub-section of lines or something, that's more difficult, and maybe even close to impossible. So again, we need you do define the problem more exactly. If the necessary operation is much more complex than a simple text-matching, then you may have to turn to a different tool that's capable of doing true xml parsing and editing.
Considering that xml structure is free-form and can easily span multiple lines, that may be a good idea in any case.