Click here to Skip to main content
Click here to Skip to main content

How to Implement IXmlSerializable Correctly

By , 26 Oct 2009
 

Introduction

Yeah, I know, this is yet another article about XML serialization... After having seen several issues in code using or demonstrating XML serialization on CodeProject (and having struggled with these issues myself!), I thought telling the community about the findings would be a good deed. After having seen the interest of people, I added some more examples in the form of source code.

There are many confusing things regarding the implementation of the IXmlSerializable interface. Even MSDN (at the time of this writing: 21.10.2009) adds confusion by publishing sample code for cases that are too simple and even these ones are wrongly implemented (See ReadXml and WriteXml from here as a starter, they work but are really wrong, you will maybe believe me after reading the full article). Many questions arise that took me a while to find a response to. That's the reason of being of this article.

Background

IXmlSerializable is composed of three methods:

  • GetSchema
  • ReadXml
  • WriteXml

The serializer created from the XML serialization attributes first has a look at if the type to be serialized implements this interface. If it is not implemented, then the public members and properties are analyzed and considered (or not thanks XmlIgnoreAttribute) for serialization.

This is a good starter. The article is clear and nicely written and introduces the main differences between attribute based serialization and implementing IXmlSerializable. IXmlSerializable.aspx is also worth reading.

After having read this article, by getting back to the other articles mentioned above, I hope you will be able to see the implementation mistakes made therein. The code works well as long as the classes do not get extended and as long as you do not mix serialization procedures. I made it all wrong too from the beginning until I dug into the problems...

This article is more or less written like a FAQ to serve as a quick reference. It should answer the most important questions one might have (or should have, hehe) asked himself regarding the implementation of IXmlSerializable. If you have more questions, please don't hesitate to contact me. I use C# as programming language. I did my best to avoid mentioning the language too much, actually this information is good for all .NET targeted languages.

Sample

To better support explanations, I introduce an example that contains many of the pitfalls that one may encounter during XML serialization. We want to serialize and deserialize animals stored as a collection in a farm. More interesting than foos and bars or?

Following aspects are present:

  1. Empty element in XML
  2. Collection interface to be serialized
  3. The collection contains elements of different types derived from a base class

Classes

public abstract class Animal
{
	public Animal() { }
	public String Name { get; set; }
	public DateTime Birthday { get; set; }
}
public class Dog : Animal
{
	public Dog() { }
}
public class Cat : Animal
{
	public Cat() { }
}
public class Mouse : Animal
{
	public Mouse() { }
}
public class Farm
{
	public Farm() { Animals = new List<Animal>(); }
	public IList<Animal> Animals { get; private set; }
}

XML Snippet

<Farm>
  <Dog Name="Rex">
    <Birthday>2009-10-22</Birthday>
  </Dog>
  <Cat Name="Tom">
    <Birthday>1940-06-15</Birthday>
  </Cat>
  <Mouse Name="Jerry" />
</Farm>

Shall GetSchema() Really Always Return Null?

YES! GetSchema() shall ALWAYS return null. This is sufficient in most cases. If you really need to provide a Schema, then use XmlSchemaProviderAttribute. GetSchema() might still be used by some legacy code or internally by .NET types, but you should not use it. It is safe and good to return null. People telling you it could be important to implement it are liars! :-)

How to Implement WriteXml?

That's the easy part, rather straight forward:

  1. Write out all attributes
  2. Write out all elements and sub objects

BUT don't write the wrapper element! That's the job of the calling code.

For our example, it means that the Dog class shall write the attribute "Name", then its element "Birthday". The Dog class shall however NOT write the "Dog" start element or its end element.

This code shows how to correctly handle all animals during WriteXml:

public void WriteXml(System.Xml.XmlWriter writer)
{
	writer.WriteAttributeString("Name", Name);
	if (Birthday != DateTime.MinValue)
		writer.WriteElementString("Birthday",
			Birthday.ToString("yyyy-MM-dd"));
}

How to Implement ReadXml?

ReadXml shall read the attributes first and then consume the wrapper element by calling ReadStartElement(). Consuming the end tag of the wrapper shall also be done inside ReadXml by calling ReadEndElement(). This sounds rather counter intuitive because WriteXml shall not write the wrapper element! But it becomes clearer if you consider reading attributes: attributes can only be read before consuming the start element they are defined for and you need to know the element name from outside the class to create a class of the correct type. NOTE: Take care of empty elements! (See below.)

For our example, it means that the Dog class shall move to the content and read the attribute "Name". Then it shall read the start element ("Dog" element is consumed but do not specify it namely). Read the elements inside the class like "Birthday" and finally consume the end element. This omits the correct handling of the case when the element is empty (no birthday specified like for Jerry for simplicity).

This code shows how to correctly handle all animals during ReadXml:

public void ReadXml(System.Xml.XmlReader reader)
{
	reader.MoveToContent();
	Name = reader.GetAttribute("Name");
	Boolean isEmptyElement = reader.IsEmptyElement; // (1)
	reader.ReadStartElement();
	if (!isEmptyElement) // (1)
	{
		Birthday = DateTime.ParseExact(reader.
			ReadElementString("Birthday"), "yyyy-MM-dd", null);
		reader.ReadEndElement();
	}
}

Are There Any Gotchas for the Implementations?

Quite a few actually:

  1. Take care of the current Culture while using ToString() inside WriteXml & reading back in ReadXml.
  2. Do not write the wrapper element in WriteXml but read it inside ReadXml!
  3. Handle empty elements correctly during deserialization.

Gotcha number 1 triggers in the case of dates, floating point values, .. that are written differently depending on the culture. In English speaking countries, it would probably display something like 10/22/2009 for Rex´s birthday. If you save that file like that and open it on another machine with a different locale, you'll get into trouble. I prefer always to specify a fixed format with the Date Time format specification for example. (A short C# Format specification Cheat Sheet I use is located here.)

Gotcha number 2 triggers if you mix both attribute driven serialization with IXmlSerializable implementation for some classes.

Gotcha number 3 triggers if elements are empty or omitted (such a surprise!).

Why are ReadXml and WriteXml Behaving Asymmetrically?

The implementation choice is good and justified because:

  1. The caller code must foresee what is the element name to create a new object of the appropriate type to be filled in during deserialization.
  2. You must be able to handle attributes in ReadXml, so the wrapping tag must not be consumed yet.
  3. You must be able to define the name of the wrapping tag from outside to allow the same type to be serialized into different container tags.

The second point is similar to saying that the rubbish does not need to know into which bin it gets into. It must only know how to describe itself and to sort itself you after you see the bin. The only counter-intuitive item is that in the case of ReadXml the rubbish opens the bin itself! But it doesn't need to know how the bin called: no argument is used for the name in ReadStartElement().

How to Handle Empty Elements?

I must say I did not find any elegant way of handling the deserialization of empty elements. No matter what I tried, I always had to perform an additional test. I found no method in the API that could help me. A suggestion to Microsoft would be to add a Boolean return value to ReadStartElement() that returns false if the element is empty. If you have an empty element, you can detect it before reading it. If you have one, then DO NOT call ReadEndElement().

For our example, it means that the Dog class shall move to the content and read the attribute "Name". BUT now comes the little difference. Store the result of IsEmptyElement into a boolean variable. Then read the start element ("Dog" element is consumed but do not specify it namely). Only if the boolean is not true, read the elements inside the class like "Birthday" and consume the end element. I really mean it, do NOT read the end element if the boolean is true. You could erroneously consume the next closing tag like in the case of the "Mouse" where you would also consume "</Animals>".

What are the Limitations of the XML Serialization Attributes?

  • Mixed mode is not supported: all text attributes get merged into a single part and you lose positional information during deserialization.
  • Serialization of interfaces is not possible, there is no declaration allowing to choose a concrete implementation for the interface.
  • Requirements on the objects have to be met (public fields and properties, default constructor, ... see this link).
  • Many .NET data structures cannot be serialized (only ICollection and IEnumerable implementations, not Dictionary for example).
  • Dynamic behaviour is not possible, it is type oriented and you cannot change the serialization depending on dynamic constraints. What if, for example, you are not interested in deserializing everything in some cases? Then IXmlSerializable saves you.

How to Realize the Same with XML Attributes?

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.ComponentModel;
using System.Text;
using System.Xml.Serialization;

namespace XmlWithAttributes
{
    public class Animal
    {
        public Animal() { }

        [XmlAttribute]
        public String Name { get; set; }

        [DefaultValue(typeof(DateTime), "0001-01-01T00:00:00")]
        public DateTime Birthday { get; set; }
    }
    public class Dog : Animal
    {
        public Dog() { }
    }
    public class Cat : Animal
    {
        public Cat() { }
    }
    public class Mouse : Animal
    {
        public Mouse() { }
    }
    public class Farm
    {
        public Farm() { Animals = new List<Animal>(); }

        [XmlElement("Dog", typeof(Dog))]
        [XmlElement("Cat", typeof(Cat))]
        [XmlElement("Mouse", typeof(Mouse))]
        public List<Animal> Animals { get; set; }
    }
}

The generated XML looks like this:

<?xml version="1.0"?>
<Farm xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance 
	xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Dog Name="Rex">
    <Birthday>2009-10-22T00:00:00</Birthday>
  </Dog>
  <Cat Name="Tom">
    <Birthday>1940-06-15T00:00:00</Birthday>
  </Cat>
  <Mouse Name="Jerry" />
</Farm>

There are some limitations though. The animals need to be stored inside a List, IList won't work, interfaces cannot be serialized. All types must be public. The date format cannot be modified by attribute declaration. To overcome these limitations, the use of an implementation of IXmlSerializable is an easy way to go.

A mixed attribute and IXmlSerializable implementation looks like this:

public class Animal : IXmlSerializable
{
	public Animal() { }
	public String Name { get; set; }
	public DateTime Birthday { get; set; }

	public System.Xml.Schema.XmlSchema GetSchema() { return null; }

	public void ReadXml(System.Xml.XmlReader reader)
	{
		reader.MoveToContent();
		Name = reader.GetAttribute("Name");
		Boolean isEmptyElement = reader.IsEmptyElement; // (1)
		reader.ReadStartElement();
		if (!isEmptyElement) // (1)
		{
			Birthday = DateTime.ParseExact(reader.
				ReadElementString("Birthday"), "yyyy-MM-dd", null);
			reader.ReadEndElement();
		}
	}

	public void WriteXml(System.Xml.XmlWriter writer)
	{
		writer.WriteAttributeString("Name", Name);
		if (Birthday != DateTime.MinValue)
			writer.WriteElementString("Birthday",
				Birthday.ToString("yyyy-MM-dd"));
	}
}
public class Dog : Animal
{
	public Dog() { }
}
public class Cat : Animal
{
	public Cat() { }
}
public class Mouse : Animal
{
	public Mouse() { }
}
public class Farm
{
	public Farm() { Animals = new List<Animal>(); }

	[XmlElement("Dog", typeof(Dog))]
	[XmlElement("Cat", typeof(Cat))]
	[XmlElement("Mouse", typeof(Mouse))]
	public List<Animal> Animals { get; set; }
}

The ReadXml() method is here tricky to implement. If you followed the guidelines correctly, the code should be similar to what is written above. If you omit the handling of an empty element (lines commented with "(1)"), deserializing the sample XML breaks on parsing "Jerry". The WriteXml() method is simple and ok, in this example it is difficult to do it in another way. But one could be tempted by writing the surrounding element in there if it were a simpler case. Here you see why it would not work in general.

The implementation overcomes the date/time issue but still has the list as a concrete class, and all members must still be public in the Farm. Note that we could already make the setters private (Name, Birthday) in the Animal class.

How to Deserialize XML Fragments?

I had to solve this to read so-called streamed XML. Not sure if it is really standard but I had to perform such a task for some projects where, let's explain it in a generic way, a source streams objects in XML all the time without a surrounding main tag. That means that actually the document would be invalid. There is a way to handle the fragments easily without having to embed them into an artificial tag. I have to dig out the code I once wrote or retry to get it right again...

This article also gives some ideas about solving this.

Feel free to ask questions and add comments, your feedback is precious to me. :-).

History

  • 2009-10-24 Added code samples and more details
  • 2009-10-22 First version released

License

This article, along with any associated source code and files, is licensed under The BSD License

About the Author

Jaap de Haan
Team Leader Alpine Electronics Research
Germany Germany
Member
As a perfectionist I enjoy working for a company aiming at excellence and where precision matters. In my opinion, writing software that works is good but writing extensible and maintainable software is better. Having a strong Architecture and Design is the first step towards a solid re-usable software platform.
 
Website: http://www.color-of-code.de

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionWhat about ReadSubtree with empty elements?memberNathan Holt13 Mar '13 - 10:50 
I found your mention of the difficulty in handling empty elements disturbing because XmlReader.ReadSubtree would have to have very counterintuitive behavior to not make it easy. What happens when you use ReadSubtree to keep from reading past an element?
To iterate is human, to recurse divine.

GeneralHow to serialize derived classes with elements and attributesmemberMarkWoodard2 Jul '12 - 6:48 
This is an excellent discussion, but leaves me wanting more.
 
Suppose in your Farm/Animal example that class Dog had two additional properties: Breed, a string written as an attribute, and Vaccinated, a DateTime written as an element. If you implemented IXmlSerializable on Dog, what would the implementation look like (essentially, how do you call the base class properly in ReadXml and WriteXml)?
GeneralMy vote of 5memberdmayer22 Mar '12 - 3:26 
After about 3 hours trying to get a mixed XMLAttribute & XmlWrite scenario to work without errors, I found this very helpful article. It could help you to save hours.
QuestionWhy does XmlSerializer work on a single object but not on a list of the same?memberMember-472225919 Aug '11 - 22:59 
I'm trying to figure out how to use XmlSerializer with a DataTable. I have a very simple object class MyClass with a couple string props. XmlSerializer can serialize an instance of MyClass to an XML file, no problem.
 
But when I try to serialize a DataTable whose rows each contain an instance of MyClass, I get an error that says Myclass cannot be serialized because it does not implement the IXmlSerializable interface. This is correct; MyClass does not implement GetSchema, ReadXml or WriteXml. Nevertheless, XmlSerializer is able to serialize a lone instance of MyClass. Why not an instance that is within a data row?
 
I am using XmlSerializer(typeof(MyClass)) and XmlSerializer(typeof(DataTable)).
 
Doug Leary

Generalgreat article - but still some questionsmemberFPDave21 Mar '11 - 14:10 
why would I get issues with deserializing a single class compared to a whole object graph.
 
My Xml looks a bit like:
 
<Entity id="2773" type="Branch">
  <PropertyValue name="name" value="fred"/>
  <PropertyValue name="IsDeliveryBranch" value="True"/>
</Entity>
 
when I have a whole graph of these it works fine, but if I serialise and de-serialise a single Entity I get issues after calling ReadStartElement after reading the id and type attributes of the opening element.
 
in Entity.ReadXml I iterate thru the PropertyValue elements inside the de-serialisation of Entity as the PropertyValue's are stored completely differently. I'm finding that the whitespace between the end oft he start element and the start of the first PropertyValue is causing me problems, and the only way to skip over it is to use reader.read(), but this seems to have other issues.
 
I have custom (de-) serialisation of the parent object which containd a collection of Entity objects, and it creates a serializer and loops thru (de-)serializing just fine. Again, its only when de-serialising a single object that I'm having trouble
 
any ideas?
GeneralRe: great article - but still some questionsmemberJaap de Haan23 Mar '11 - 3:56 
I would implement the reading of Entity according to this pattern:
 
	reader.MoveToContent ();
	Id = reader.GetAttribute ("id");
	Type = reader.GetAttribute ("type");
 
	reader.ReadStartElement (); // *** consume start Entity tag and position to the first Property value
	while (reader.IsStartElement ("PropertyValue")) {
		// read the property value
	}
	reader.ReadEndElement (); // consume </Entity>
 
If this hint (***) doesn't help feel free to send me your code/xml file for me to have a deeper look.
GeneralRe: great article - but still some questionsmemberFPDave24 Mar '11 - 0:45 
If i follow what you say then it doesnt move off the first PropertyValue element and is stiuck in an endless loop, but if I add a ReadStartElement after your "// read the property value" comment then its fine, as it moves on to the next PropertyValue element. I suspect you assumed I might be reading PropertyValue using a specific class, but the property values are actually stored in a List of name value pairs.
 
My working code now looks like:
		public void ReadXml(XmlReader reader)
		{
			reader.MoveToContent();
 
			string v = reader.GetAttribute("id");
			this.ID = Int32.Parse(v);
			v = reader.GetAttribute("TypeOfEntity");
 
			bool isEmptyElement = reader.IsEmptyElement;
			reader.ReadStartElement();
 
			if (!isEmptyElement)
			{
				// now for each of the property value elements)
				while (reader.IsStartElement(constXmlPropertyValueElementName))
				{
					string propname = reader["Name"];
					string propval = reader["Value"];
					// store the property values (omitted)
					reader.ReadStartElement();
				}
				reader.ReadEndElement();
			}
		}
 
anyway, its now working fine thanks to your input, much appreciated
GeneralFantastic Article!memberMark Olbert29 Jan '11 - 6:03 
I was completely befuddled as to how to implement this interface until I read your article. Thanks!!!! Smile | :)
GeneralMy vote of 5memberMario Majcica9 Jan '11 - 22:47 
Your English is more than good enough. Wink | ;) Nice job, thanks.
GeneralGood articlememberEmpolized21 Sep '10 - 22:20 
Thanks!   Smile | :)
GeneralMy vote of 2membergoldsam14 Sep '10 - 9:08 
Poor article structure, poor english, shows naive understanding of core concepts
GeneralRe: My vote of 2memberJaap de Haan2 Jan '11 - 22:05 
Regarding my english, as non native speaker, I try my best. I agree that is is probably not good enough Frown | :-( But what I am interested in is what exactly looks bad in the technical aspect of the article. The pitfalls and problems I faced are real ones regarding this topic. I could find no proper explanation/example in the official documentation (I mean, one that worked in all cases). If you have a better reference or source for the implementation of IXmlSerializable, I would be very glad to get it. Thank you anyway for your honest feedback.
QuestionGetSchema shall always return null. Why?memberMathieu CARTOIXA30 Aug '10 - 22:05 
Good article. But do you have more rationale on why GetSchema should always return null?
AnswerRe: GetSchema shall always return null. Why?memberJaap de Haan31 Aug '10 - 9:27 
If providing schema information is necessary, you should use the XmlSchemaProviderAttribute attribute. The GetSchema is not used by the XmlSerializer, because it does not perform validation. Some .NET internals or other legacy code might use this method but consider it as obsolete or reserved for internal use. See http://msdn.microsoft.com/en-us/library/system.xml.serialization.ixmlserializable_methods.aspx[^].
GeneralRe: GetSchema shall always return null. Why?memberMathieu CARTOIXA31 Aug '10 - 20:21 
Thanks for your answer. I had read the link you provided, and found it very light (to say the least) on the why topic. Even if this method is there for historical reasons, I would expect a more thorough explanation somewhere about why it was there in the first place, and about the new design choices. But documentation is hard (I know that).
 
My question comes from the fact that I have a scenario that may be too much out of the box: I have a custom type T which is serializable in XML. The content of T instances is mostly defined at runtime (not through reflection). When an instance is serialized, the schema that is used for validation depends on its content. In this scenario, you can understand that an instance methode like GetSchema looks more appropriate than the static method required by the XmlSchemaProvider attribute.
QuestionProcess collection with the IXmlSerializable approachmemberNaeemIsmail27 Apr '10 - 22:47 
Jaap,
 
Great article, concise and to the point. I do have one question though. How would you propose someone should process a collection of elements using the IXmlSerializable approach. For example:
 

<Farm>
<Animals>
<Dog/>
<Cat/>
</Animals>
<Farm>

 

Any clarification appreciated.
NaeemI

AnswerRe: Process collection with the IXmlSerializable approachmemberStefan Cronert28 Apr '10 - 2:51 
Try this in your collection class
Public Sub ReadXml(ByVal reader As System.Xml.XmlReader) Implements System.Xml.Serialization.IXmlSerializable.ReadXml
'move to the content
reader.MoveToContent()
Dim isEmpty As Boolean
'is there any data
isEmpty = reader.IsEmptyElement()
'get to the start node of the items in the collection
reader.ReadStartElement()
If (Not isEmpty) Then
  'as long as there is a data (items in the collection) the reader has a start element
  While (reader.IsStartElement)
    Dim item As ChildItem
    item = New ChildItem()
    item.ReadXml(reader)
    Me.Add(item)
  End While
'read the close tag for the collection
reader.ReadEndElement()
End If
End Sub

AnswerRe: Process collection with the IXmlSerializable approachmemberJaap de Haan29 Apr '10 - 11:11 
You are right the information is missing. Writing the animals out is a childplay: go through each animal and call the WriteXml method (in some way you will also have to write out the type of animal). Reading back is more difficult as you will have to know which kind of animal to rebuild from the XML. That is why serialization of interfaces is not working that easily with XmlSerialization attributes. To read back you will have to store the type information in some way during writing and use that information during reading to rebuild the correct objects. This is also done by the attribute based serialization. I have at the moment unfortunately very less time Cry | :(( but I will try to provide you an implementation example as soon as I can. Maybe this hint will already help you out. Big Grin | :-D
Generaluse XmlConvert insteadmembersyu5 Apr '10 - 0:08 
always use XmlConvert to read/write to xml file.
not object.ToString()
GeneralRe: use XmlConvert insteadmemberJaap de Haan5 Apr '10 - 4:43 
Thanks, very good point I had overseen. I will fix that as soon as I get some free time.
QuestionAutomatically serialize *some* properties?memberCiantic24 Nov '09 - 3:18 
How can we serialize "normally", (meaning the same way the automatical XmlSerialization does) some properties when using IXmlSerializable? I want to "manually serialize" only part of the properties, not all.
 
E.g.
    
    public class Widget : UserControl, IXmlSerializable
    {
        public List<SomeSerializableObject> SomeList = new List<SomeSerializableObject>();
        
        #region IXmlSerializable Members
 
        public virtual System.Xml.Schema.XmlSchema GetSchema()
        {
            return null;
        }
 
        public virtual void ReadXml(System.Xml.XmlReader reader)
        {
            // How can we read the SomeValue using normal serialization? Like without IXmlSerializable
        }
 
        public virtual void WriteXml(System.Xml.XmlWriter writer)
        {
            // How can we write the SomeValue using normal serialization? Like without IXmlSerializable
        }
 
        #endregion
    }

 
modified on Tuesday, November 24, 2009 10:13 AM

AnswerRe: Automatically serialize *some* properties?memberJaap de Haan29 Nov '09 - 0:56 
The use of attribute serialization is possible inside the Read/WriteXml methods. Just take the XmlReader/XmlWriter stream instead of creating a stream from a file like in this example for Animal and Birthday (stays for SomeValue in your question).
 
        public void ReadXml(System.Xml.XmlReader reader)
        {
            reader.MoveToContent();
            Name = reader.GetAttribute("Name");
            Boolean isEmptyElement = reader.IsEmptyElement;
            reader.ReadStartElement();
            if (!isEmptyElement)
            {
                XmlSerializer s = new XmlSerializer(typeof(DateTime));
                Birthday = (DateTime)s.Deserialize(reader);
                reader.ReadEndElement();
            }
        }
        public void WriteXml(System.Xml.XmlWriter writer)
        {
            writer.WriteAttributeString("Name", Name);
            if (Birthday != DateTime.MinValue)
            {
                XmlSerializer s = new XmlSerializer(typeof(DateTime));
                s.Serialize(writer, Birthday);
            }
        }
 
If you followed the different rules deserialization should work properly. However, for base types (DateTime, String, ...) it does not make much sense, as you cannot control very well how the tags will be called but for serializing members that are classes it will work like a charm. (Maybe there is a way to give them names but I do not know it...)
 
I hope this helps.
AnswerRe: Automatically serialize *some* properties?memberDEGT4 Jan '12 - 5:31 
I found myself in the same spot and solved it. In my case I needed that the DateTime field be serialized in a specific format (R, RFC1163?) rather than the default DateTime format AND that the DateTime attribute be serialized ONLY under certain circumstances.
 
I solved that in a simple way in the WriteXml() method of the IXmlSerializable implementation. Therein you should check if the attribute serialization condition is met and if so use WriteAttributeString() otherwise skip it.
http://www.coralys.com/
http://www.virtual-aviation.net/

GeneralRe: Automatically serialize *some* properties?memberjdstuart12 Jun '12 - 6:41 
I've ran into the same problem yesterday.
 
Any chance you can post an example of how you managed to do this?
Questionsome code examples ?memberBillWoodruff23 Oct '09 - 20:54 
Hi Jaap,
 
I am sure this article provides excellent clarifications for those already experienced in writing/reading XML, but for those of us with relatively trivial experience (like me !), I have trouble understanding the points you are making, and I am not going to switch back and forth between MSDN examples and your comments trying to figure out what you are doing differently (I already get headaches just reading MSDN Smile | :) .
 
If you care to expand this article with a few simple examples of what you consider "optimized" examples of reading and writing XML, I know I would benefit : perhaps others would benefit, too.
 
thanks, Bill
 
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 26 Oct 2009
Article Copyright 2009 by Jaap de Haan
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid