XML serialization attribute/element class syntax question

  • Thread starter Thread starter Richard.Haggard
  • Start date Start date
R

Richard.Haggard

Guest
How is the class that will be associated with this XML line be defined:


<Area unit="sf">5,046</Area>

So it looks like we'll have something like this:

[Serializable]
public class Area
{
[XmlAnyAttribute] public string unit;
}

But what about the actual node data itself of 5,046? How would one define the class so as to be able to deserialize the node's value?

Another question, what needs to be done so that the class will accept an Area node whose unit attribute is null and whose value is empty?

Another question, what needs to be done so that the class will deserialize a file that doesn't include the Area node at all? In other words, does not throw an exception if the Area node doesn't exist or if the unit attribute doesn't exist?



Richard Lewis Haggard

Continue reading...
 
Back
Top