M
Marc Gravell
Is there an easy way to (efficiently) walk the entire contents of an
XmlReader? For instance, I have an XmlReader returned from a "FOR XML"
SQL query (ExecuteXmlReader), and I want to return this data to the
caller through a stream.
One option is to use:
XmlDocument doc = new XmlDocument();
doc.Load(reader);
doc.Save(stream);
but obviously this unnecessarily loads the DOM; likewise,
reader.ReadOuterXml() forces the entire xml to load into a string at
once... but the xml in question could be quite large. I was hoping for
a stream-like way to walk the nodes, writing to the stream (either
directly, or via an XmlWriter).
Does anybody have any hints here?
Marc
XmlReader? For instance, I have an XmlReader returned from a "FOR XML"
SQL query (ExecuteXmlReader), and I want to return this data to the
caller through a stream.
One option is to use:
XmlDocument doc = new XmlDocument();
doc.Load(reader);
doc.Save(stream);
but obviously this unnecessarily loads the DOM; likewise,
reader.ReadOuterXml() forces the entire xml to load into a string at
once... but the xml in question could be quite large. I was hoping for
a stream-like way to walk the nodes, writing to the stream (either
directly, or via an XmlWriter).
Does anybody have any hints here?
Marc