Question

I am trying to create a xml-structre from a name/value-pairs. This works with a xmlwriter. Now I would like to transform this xml.

I think that the best way is to use the xmlwriter as source for the xmlreader to to the transform. But I don't know how to set the xmlwriter as source for the xmlreader.

How can I do this?

Was it helpful?

Solution

You could use a MemoryStream for example.

MemoryStream stream = new MemoryStream();
using (XmlWriter writer = XmlWriter.Create(stream))
{
    // Do some stuff with writer
}

stream.Seek(0, SeekOrigin.Begin); // Reset stream position to read from the beginning.

using (XmlReader reader = XmlReader.Create(stream))
{
    // Do some stuff with reader
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top