Tuesday, April 20, 2010

A trip down the .Net 4 System.Xml path, some pitfalls and how you can avoid them

CodeProject - Common Pitfalls in System.Xml 4.0

“Pitfalls in working with DTD's, duplicate namespaces, significant whitespace and SchemaSets; includes new and obsolete features in System.XML 4.0

Introduction

Download the source: Download XmlTests.zip - 128.6 KB [GD: Click through for the link]

Download the PDF: Download Common_Pitfalls_in_System.Xml_4.0.pdf - 189.44 KB [GD: Click through for the link]

This small session presents my own research behind some of the pitfalls found in System.Xml and child namespaces. We’ll be discussing :

  • non-obvious differences between XDocument and XmlReaders/Writers
  • namespace handling with duplicate namespace declarations
  • how to properly treat mixed-content XML files
  • difficulties with Streams and SchemaSet

Finally we’ll take a look at what’s been made obsolete and what’s brand new in the different namespaces in System.Xml for .NET 4.0.

You will need:

  • Visual Studio 2010 (most will work with VS2008 SP1 too)
  • A strong base of C# and XML, working knowledge of XPath and XSLT to understand every example. If you also know DTD’s and XML Schema’s all the better!

This session is not intended to teach you about how to process basic XML files in C#, you should know this already, sorry!

If you’re in a hurry, skip forward to the conclusions of each topic, everything in between is background information or proof.

I hope this research helps you avoid bugs in the future and help you pay attention to some specific pitfalls found in System.Xml

…”

The PDF;

image

As we move to .Net 4, lets learn from each other and not waste time running into and solving the same problems… Kudos to Kurt for taking the time to write this up and share it.

1 comment:

James Barrow said...

Hi Greg,

The link to the CodeProject article is broken, here's the link to the actual CodeProject article.

Cheers,

James