XMLElement name not changing when serializing to XML

Jun 26, 2008 at 2:12 PM
Edited Jun 26, 2008 at 2:15 PM
I've been trying to enable output to xml of Photoset thumbnail properties by adding the relevant attribute, but there was no change to the xml.
So I've changed the PhotoSet.cs as below from

[XmlAttribute("id")] 
public string PhotosetId
{
get { return _photosetId; } set { _photosetId = value; }
}

to....... 
[XmlAttribute("idtest")] 
public string PhotosetId
{
get { return _photosetId; } set { _photosetId = value; }
}


and now the id attribute is not rendered at all when i'd expect ot render similar to idtest="klj".

Am I missing something?

 

 

 

 

 

 

Jun 26, 2008 at 3:06 PM
seems I found the solution

it is due to properties having no set{} method that the XMLSerializer does not output their value
Coordinator
Jun 27, 2008 at 3:12 PM
Yeah, the XmlSerializer can be weird like that. It has to have a public getter and setter to work the other way I know.