I need to remove XML tag in a string which ends with "section". For example in the below XML string
<OldSection>
<sectionTitle>Sample Title</sectionTitle>
<label> Hello Label </label>
<heading>Hi </heading>
<NewSection>
<section>
<InteractionSection>
<sectionTitle>Section Title</sectionTitle>
<label> Hello </label>
<heading>Hi </heading>
<para>
...
...
</para>
</InteractionSection>
<section>
</NewSection>
</OldSection>
I want to remove tags which ends with section i.e <OldSection>, </OldSection>
,<NewSection></NewSection>, <InteractionSection>, </InteractionSection> etc. The tag alone should be removed and not the contents with in the tag.
I tried the following code but not working..
stringformat sf = new stringformat();
// REturns the xml string given as input
String s = sf.getString();
String f = s;
f = f.replaceAll("\\<*Section[^>].*?\\>", "");
Please any suggestions.
\\<.*Section>