0

Hi all,
I got the following XML C# string:

<Grocery>
            <Food>
                        <Fresh Food>
                                    <fruit>BANANA</fruit>
                                    <meat>CHICKEN</meat>
                                    <desert>CAKE</desert>
                        </Fresh Food>
            </Food>
            <Food>
                        <Fresh Food>
                                    <fruit>APPLE</fruit>
                                    <meat>BEEF</meat>
                                    <desert>PIE</desert>
                        </Fresh Food>
            </Food>
</Grocery>

I want to remove the Fresh Food tags to obtain the following:

<Grocery>
            <Food>
                                    <fruit>BANANA</fruit>
                                    <meat>CHICKEN</meat>
                                    <desert>CAKE</desert>
            </Food>
            <Food>
                                    <fruit>APPLE</fruit>
                                    <meat>BEEF</meat>
                                    <desert>PIE</desert>
            </Food>
</Grocery>

Someone have an idea of how to do this with C# code or XLST in C#?
Thanks

2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by DdoubleD
0
myString.Replace("<Fresh Food>", "");
myString.Replace("</Fresh Food>", "");

Include newline if you want that removed too:

myString.Replace("<Fresh Food>\n", "");
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.