1

Can you please help me to extract strings between xml tags. xml input:

    <Name ns1:translate="yes">Overview</Name>
    <Title ns1:translate="yes">This is a book</Title>
    <Description ns1:translate="yes"/>
    <TextValue ns1:translate="yes">End</TextValue>

Expected output:

    Overview = Overview
    This is a book = This is a book
       =
    End = End
1
  • If you'll have to do more work with XML then you might want to use/learn XPath and XQuery. Commented Aug 7, 2012 at 10:12

2 Answers 2

3

If you want just remove tags, you can do it this way:

$ sed 's/<[^>]*>//g'

If you want to repeat the text in tags, you need something like:

$ sed 's/.*>\([^<]*\)<.*/\1 = \1/g'
Sign up to request clarification or add additional context in comments.

Comments

2

One suggestion: Please use PERL for XML read/extraction. PERL has many modules XML parsing modules [both SAX/DOM].

OR even Python is perfect choice for XML parsing.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.