Home > SOA Tips > .NET Developer > Using an XML reader
SOA Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

.NET DEVELOPER

Using an XML reader


Dan Fox
01.21.2003
Rating: -3.00- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



.NET Developer Tip
(Receive this column in your inbox,
click Edit your Profile to subscribe.)

Using an XML reader
Dan Fox

If you've been using XML for document transfers and integration to backend processes in your company, then you need to be able to read them and transfer them from one place to the other. This tip, excerpted from InformIT, discusses how to use an XML reader to gobble up those XML docs and get them to where they're supposed to go.

Dan Fox is the author of Building Distributed Applications with Visual Basic .NET, published by Quilogy, Inc. The article from which this tip comes is included in a chapter of this book.


When the DOM was first published and vendors such as Microsoft began writing parsers like MSXML to read those documents, it became immediately apparent that the programming model was not ideal for all applications. This was particularly the case when the XML document was large, since by definition the DOM represents the entire document in an in-memory tree structure. Not only did performance suffer using the DOM since you had to wait for the document to be parsed and loaded, but the application processing the document tended to eat up significant amounts of memory. As a result, Microsoft included the SAX APIs in MSXML 3.0 to provide an event-driven programming model for XML documents. While this alleviated the performance and memory constraints of the DOM, it did so at the cost of complexity.

The XmlReader implementation is in many ways a melding of the DOM and SAX and provides a simplified programming model like the DOM but in a stream-based architecture. The programming model is simplifi


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Microsoft .NET Web services
How do I balance throughput requirements and interoperability?
APM software traces transactions across tiers, technologies
How you can learn M Grammar for Oslo modeling
Legacy modernization opens Windows for publisher
Former .NET Web developers ride Ruby and Rails application framework
Microsoft Oslo at PDC: Dial 'M' for modeling language
Yahoo proxy fight looms
New Microsoft site for architects
LAMP coders go hybrid route
Silverlight shines on bank RIAs
Microsoft .NET Web services Research

Web Services Basics
Gartner Summit round-up
Denmark is first to adopt Universal Business Language
XML-based financial standard gets new support
SOAP test tool adds WS-Security, MIME support
Survey: IT spending back from the dead
WASP Server adds to XML Schema support
IBM, Microsoft on opposite sides of standards fence
WS orchestration 'power struggle' under way, IDC says
Management tools raise privacy alarms
Internet millionaire gives integration a whirl

.NET Developer
Programming Indigo
DataSets and Web services don't mix
Security in .NET 2.0
Tracking down managed memory leaks
Handling exceptions in .NET
.NET Compact Framework graphics
The Data Access Application Block
A great .NET resource: .Net2TheMax
Delegates vs. interfaces in .NET
Project structure best practices

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
Common Language Infrastructure  (SearchSOA.com)
Visual J#  (SearchSOA.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


ed because it is a pull rather than a push model. In other words, developers pull data from the document using a familiar cursor-style looping construct rather than simply being pushed data by responding to events fired from the parser.

The XmlReader class is actually an abstract base class for the XmlTextReader, XmlValidatingReader, and XmlNodeReader classes. The XmlReader is often used as the input or output arguments for other methods in the Services Framework. A typical use of the XmlTextReader is to read XML produced from the FOR XML statement in SQL Server 2000 and then load a DataSet object as shown in the following code:

Note that the ExecuteXmlReader method of the SqlCommand object returns an XmlReader which is then accepted as an argument to one of the overloaded ReadXml methods of the DataSet object. As discussed in Chapter 7, the second argument to the ReadXml method specifies how the XML is parsed using one of the XmlReadMode constants.

As implied by the names, XmlTextReader simply provides a reader that checks for well-formedness of an XML document and any inline DTDs but does not perform validation using an associated DTD or schema as does XmlValidatingReader. As a result, XmlTextReader is the fastest way to parse an XML document using a file, Stream, or TextReader as input. XmlNodeReader, on the other hand, can parse XmlNode objects from an XML DOM subtree.


To read the entire tip from which this article is excerpted, click over to InformIT. You have to register there, but the registration is free.

For More Information:


Rate this Tip
To rate tips, you must be a member of SearchSOA.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



SOA Trends and Strategy - SOA Education, SOA Development, SOA Implementations
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2001 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts