Maybe I'm not doing this correctly. But I'm using MusicXML, along with XSD.exe to generate the C# classes against the DTD.
According to the documentation, along with a sample xml file, the <NOTE>
element contains an empty <CHORD>
element, if the <NOTE>
is a part of a <CHORD>
. The code generated looks like this:
[System.Xml.Serialization.XmlElementAttribute("chord", typeof(empty))]
When I deserialize the XML into a c# object, it works great, but the <CHORD>
seems to disappear. Does .NET just ignore the CHORD
element in this sample XML?
<note>
<chord/>
<pitch>
<step>E</step>
<alter>-1</alter>
<octave>4</octave>
</pitch>
<duration>1</duration>
</note>
Thanks!
Do you mean the chord element dissapears when you serialize to XML, as null elements don't serialize by default
If you want to render it as an empty element like
<chord />
you can set use the isnullable property XML Serialization and null value - C#
As linked in another question you might want to have a look at this article about the representation of null in XML Schema files:
http://www.ibm.com/developerworks/xml/library/ws-tip-null/index.html