Serializing XML element with scope in .NET
-
I have a class that contains elements: class MyClass { int var1; string var2; } I'm using the XmlSerializer class to output objects of MyClass to an XML stream and I'm trying to work out how to get the output to be like: ... Value 1 Value 2 ... I've played around with the XmlElementX attributes classes but no luck. The XmlElement.Prefix property seems to be one solution, except that the compiler barfs saying Prefix isn't a member (contradicting the docs and intellisese). Any ideas? cheers, Chris Maunder
-
I have a class that contains elements: class MyClass { int var1; string var2; } I'm using the XmlSerializer class to output objects of MyClass to an XML stream and I'm trying to work out how to get the output to be like: ... Value 1 Value 2 ... I've played around with the XmlElementX attributes classes but no luck. The XmlElement.Prefix property seems to be one solution, except that the compiler barfs saying Prefix isn't a member (contradicting the docs and intellisese). Any ideas? cheers, Chris Maunder
chris you need to use
XmlSerializerNamespaces
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlserializationxmlserializernamespacesclasstopic.asp[^]
"When the only tool you have is a hammer, a sore thumb you will have."
-
chris you need to use
XmlSerializerNamespaces
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlserializationxmlserializernamespacesclasstopic.asp[^]
"When the only tool you have is a hammer, a sore thumb you will have."
Thanks! cheers, Chris Maunder