0

Consider the xml below. In C# code, I'm using System.Xml.Serialization to serialize my classes. In my Display class I want to reference the Category object serialized below Categories. Note the use of IDREF.

How do I declare the class attributes to accomplish this?

<?xml version="1.0" encoding="utf-8"?>
<data>
    <categories>
        <category id="google">
            <name>Google</name>
        </category>
    <categories>
    <display>
        <categories>
            <category idref="google"/>
        </categories>
    </display>
</data>

And in C#:

// Display class...

[XmlArray(ElementName = "categories")] // IDREF?
[XmlArrayItem(ElementName = "category")] // IDREF?
public Category[] Categories
{
    get;
    set;
}
l33t
  • 18,692
  • 16
  • 103
  • 180
  • http://stackoverflow.com/questions/1617528/net-xml-serialization-storing-reference-instead-of-object-copy – rodrigogq Jun 17 '15 at 17:02
  • Too bad :( But I suppose that I can easily convert my code to use DataContract instead... – l33t Jun 17 '15 at 18:13

0 Answers0