469,920 Members | 2,349 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,920 developers. It's quick & easy.

TextReader onto an XmlDocument.

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
Nov 12 '05 #1
1 2338
Colin Green wrote:
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.


Have you tried XmlNodeReader [1] ?

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

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Martin Honnen | last post: by
2 posts views Thread by Graham Pengelly | last post: by
8 posts views Thread by pete | last post: by
3 posts views Thread by Chan | last post: by
2 posts views Thread by Bryan Dickerson | last post: by
3 posts views Thread by trint | last post: by
3 posts views Thread by Tony Johansson | last post: by
reply views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.