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?
XmlWriter is an abstract class. XmlTextWriter is a specific implementation of XmlWriter .
Overloads. Creates a new XmlWriter instance using the StringBuilder and XmlWriterSettings objects. Creates a new XmlWriter instance using the filename and XmlWriterSettings object. Creates a new XmlWriter instance using the TextWriter and XmlWriterSettings objects.
Creates a new XmlReader instance using the specified stream with default settings. Creates a new XmlReader instance by using the specified URI and settings.
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With