471,594 Members | 1,690 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,594 software developers and data experts.

SAX model and XmlTextReader

Does XmlTextReader class in .net represent SAX implementation?

If yes, are there any performance gains if I use C++ SAX implementation in
msxml4.dll versus XmlTextReader in .net? Did any one try this?

If no, what is the .net class that implements SAX model?

Thanks.
Raghu/..
Nov 12 '05 #1
3 3085


Raghu wrote:
Does XmlTextReader class in .net represent SAX implementation?
No, SAX is a push model while XmlTextReader is a pull model.
If yes, are there any performance gains if I use C++ SAX implementation in
msxml4.dll versus XmlTextReader in .net? Did any one try this?

If no, what is the .net class that implements SAX model?


There is no class in .NET SDK 1 or 1.1 that implements SAX however
searching with Google should find some third party implementations

--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #2
So what are the implications of following code:

XmlTextReader tr = new XmlTextReader(sessionXml, XmlNodeType.Document,
null);

while (tr.Read())

{

if (tr.NodeType == XmlNodeType.Element && tr.LocalName == "myElement")

{

//TODO

}

}

Does the first line of code (creating XmlTextReader object with xml string)
parse the entire session xml? Does it parse only one xml node at a time when
Read method is called?

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:ug****************@TK2MSFTNGP12.phx.gbl...


Raghu wrote:
Does XmlTextReader class in .net represent SAX implementation?


No, SAX is a push model while XmlTextReader is a pull model.
If yes, are there any performance gains if I use C++ SAX implementation in msxml4.dll versus XmlTextReader in .net? Did any one try this?

If no, what is the .net class that implements SAX model?


There is no class in .NET SDK 1 or 1.1 that implements SAX however
searching with Google should find some third party implementations

--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #3
Parsing happens in chunks, through an internal buffer the internal
XmlScanner keeps. When you compare local names aganst strings, you should
use reference comparison by taking advantage of the built-in string
"atomization" that happens as the parsing occurs:

object el = tr.NameTable.Add( "myElement" );
while (tr.Read())
{
if (tr.NodeType == XmlNodeType.Element && tr.LocalName == el)

As "el" is declared as object, a fast reference comparison will be
performed.

--
Daniel Cazzulino [MVP XML]
Clarius Consulting SA
http://weblogs.asp.net/cazzu
http://aspnet2.com

"Raghu" <Ra***@nospamzzzqcsi.com> wrote in message
news:O1**************@TK2MSFTNGP11.phx.gbl...
So what are the implications of following code:

XmlTextReader tr = new XmlTextReader(sessionXml, XmlNodeType.Document,
null);

while (tr.Read())

{

if (tr.NodeType == XmlNodeType.Element && tr.LocalName == "myElement")

{

//TODO

}

}

Does the first line of code (creating XmlTextReader object with xml string) parse the entire session xml? Does it parse only one xml node at a time when Read method is called?

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:ug****************@TK2MSFTNGP12.phx.gbl...


Raghu wrote:
Does XmlTextReader class in .net represent SAX implementation?
No, SAX is a push model while XmlTextReader is a pull model.
If yes, are there any performance gains if I use C++ SAX
implementation in msxml4.dll versus XmlTextReader in .net? Did any one try this?

If no, what is the .net class that implements SAX model?


There is no class in .NET SDK 1 or 1.1 that implements SAX however
searching with Google should find some third party implementations

--

Martin Honnen
http://JavaScript.FAQTs.com/


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.679 / Virus Database: 441 - Release Date: 07/05/2004
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Hang Cheng | last post: by
4 posts views Thread by Andy Neilson | last post: by
5 posts views Thread by Geoff Bennett | last post: by
5 posts views Thread by Chris | last post: by
2 posts views Thread by XML reading with XMLTextReader | last post: by
4 posts views Thread by CodeRazor | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.