1

「セクション」で終わる文字列の XML タグを削除する必要があります。たとえば、以下の XML 文字列では

<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>

セクション ie などで終わるタグを削除したい<OldSection>, </OldSection> ,<NewSection></NewSection>, <InteractionSection>, </InteractionSection>。タグ内のコンテンツではなく、タグのみを削除する必要があります。

次のコードを試しましたが、うまくいきません..

stringformat sf = new stringformat();

// REturns the xml string given as input 
String s = sf.getString(); 
String f = s; 

f = f.replaceAll("\\<*Section[^>].*?\\>", "");

提案をお願いします。

4

1 に答える 1