Add <root> node to XML / Encapsulate XML in <root>

I have an XML file. It is structuered like this ..

<RECIPES>
  <RECIPE id="1836" category="Entrees:Sandwiches/Wraps:Meat" portionsize="1 each">Sandwich, "Blazing Wilbur"</RECIPE>
  <RECIPE id="4800" category="Entrees:Sandwiches/Wraps:Meat" portionsize="1 sandwich">Sandwich, "Chicken Monterey"</RECIPE>
</RECIPES>

I need to encapsulate the entire file in the <root> node automatically. so its like this..

<root>
 
<RECIPES>
  <RECIPE id="1836" category="Entrees:Sandwiches/Wraps:Meat" portionsize="1 each">Sandwich, "Blazing Wilbur"</RECIPE> 
  <RECIPE id="4800" category="Entrees:Sandwiches/Wraps:Meat" portionsize="1 sandwich">Sandwich, "Chicken Monterey"</RECIPE> 
</RECIPES>
 
</root>

Open in new window

LVL 2
BharBharAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kaylanreilorCommented:
Why don't you edit it manually to add it with notepad ?
0
BharBharAuthor Commented:
i am getting a feed, which i need to import regularly. so its a fresh file .. i think it can be done with XSLT but i need direction.
0
kaylanreilorCommented:
If you want to do it programmatically you should investigate through the System.Xml namespace. You should play with the classes XmlDocument, XmlNode, XmlNodeList...
Is that where you want to go ?
0
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

kaylanreilorCommented:
Are you developping an application ?
0
BharBharAuthor Commented:
Yes. I just need the XSLT. I have everything else in place.
0
Geert BormansInformation ArchitectCommented:
Here is all the XSLT you need

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
    <root>
        <xsl:copy-of select="."/>
    </root>
</xsl:template>
</xsl:stylesheet>

it is simple, so yes, this is best done using XSLT

cheers

Geert
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BharBharAuthor Commented:
May peace be with you. You are a genius.
0
Geert BormansInformation ArchitectCommented:
welcome
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.