Construct xml file in memory


I have to create a class which construct an xml file in memory (means not in a file) with tags and specific values and return that file to the calling method).

How can i do that?

Who is Participating?
AlexFMConnect With a Mentor Commented:
You can create XmlDocument instance which is actually memory representation of XML file. XmlDocument constructor creates empty XML document. Then use AppendChild to add root node, and XmlNode.AppendChild to add childs to root node. You can return XmlDocument instance to the caller.
You can also save XmlDocument to MemoryStream using XmlDocument.Save(Stream) method. Stream is organized like file and can be handled by client like FileStream created from XML file. You can decide to return Stream instance to the caller. In this case caller can handle return value by the same way as FileStream.
Rahamathulla_JAuthor Commented:

I want to construct this same like xml file in memory?

xml version="1.0" encoding="utf-8" ?>
- <BP>
- <Message status="CREATED" identifier="786">


- <Sign>
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.