Connecting Tech Pros Worldwide Help | Site Map

TextReader onto an XmlDocument.

Colin Green
Guest
 
Posts: n/a
#1: Nov 12 '05
Hi I wonder if anyone has any ideas about this...

I am dumping the contents of an XmlDocument into a RichTextBox so the
user can see the raw XML. I use a line of code something like this to
lado the Xml text into the textbox:

richTextBox.Text = xmlDoc.ToString();


I recon this technique is inefficient with large xml documents.
Firstly the XmlDocument's raw xml text is dumped to a large string,
then that string is loaded into the richTextBox in one large chunk.

To alleviate these two performance hits I have the option of using an
alternative text editor that may be able to load text from some kind
of stream. My question then; is there an existing framework class that
will provide something akin to a TextReader interface onto an
in-memory XmlDocument? I have looked through the framework docs and on
google with no luck.

If there is no existing class I think I can create one by wrapping an
XmlWriter within a class that exposes a TextReader type interface.
When the caller requests to read more bytes I can check an internal
buffer, if there are no bytes in the buffer then I can generate more
bytes by asking the writer to write the next XmlNode to the buffer.

Does this seem like a reasonable way of achieving my goal or does
anyone know of some part fo the framework that would allow me to do
this without writing a new class?

Thanks,

Colin Green
Oleg Tkachenko
Guest
 
Posts: n/a
#2: Nov 12 '05

re: TextReader onto an XmlDocument.


Colin Green wrote:
[color=blue]
> To alleviate these two performance hits I have the option of using an
> alternative text editor that may be able to load text from some kind
> of stream. My question then; is there an existing framework class that
> will provide something akin to a TextReader interface onto an
> in-memory XmlDocument? I have looked through the framework docs and on
> google with no luck.[/color]

Have you tried XmlNodeReader [1] ?

[1]
http://msdn.microsoft.com/library/de...classtopic.asp
--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog

Closed Thread