Using xmlserialization to create an xml document...have a question [modified]
-
I'm taking data from a database and feeding it into an application that takes an XML file as input. One of their fields is basically an enumerator value so I created a class that would attach the attribute to the field:
StaticType<int;> contractType; ... \[Serializable\] public class StaticType<T> { public StaticType( ) { } public StaticType( T initialValue ) { internalValue = initialValue; initialValue = index; } private T initialValue; private int initialIndex; \[XmlAttribute(AttributeName="staticValue")\] public T InternalValue { get { return initialValue; } set { initialValue = value; } } }
The output works great and I get a field as such:
<someDataType staticValue="1" />
Here is the question: Reading further into the documentation it looks like I might have to pass the value for some reason as well. So I'm puzzled as to how to construct the class so that my output gets created as:<someDataType staticValue="1">some text value</someDataType>
Any ideas?modified on Tuesday, February 19, 2008 1:17 PM
-
I'm taking data from a database and feeding it into an application that takes an XML file as input. One of their fields is basically an enumerator value so I created a class that would attach the attribute to the field:
StaticType<int;> contractType; ... \[Serializable\] public class StaticType<T> { public StaticType( ) { } public StaticType( T initialValue ) { internalValue = initialValue; initialValue = index; } private T initialValue; private int initialIndex; \[XmlAttribute(AttributeName="staticValue")\] public T InternalValue { get { return initialValue; } set { initialValue = value; } } }
The output works great and I get a field as such:
<someDataType staticValue="1" />
Here is the question: Reading further into the documentation it looks like I might have to pass the value for some reason as well. So I'm puzzled as to how to construct the class so that my output gets created as:<someDataType staticValue="1">some text value</someDataType>
Any ideas?modified on Tuesday, February 19, 2008 1:17 PM
Using Xml serialization, you cannot have that construct. Instead, it would looks something like:
<someDataType staticValue="1"><Value>some text value </Value></someDataType>
You would require another property in your object, named Value (or whatever name you chose). -
Using Xml serialization, you cannot have that construct. Instead, it would looks something like:
<someDataType staticValue="1"><Value>some text value </Value></someDataType>
You would require another property in your object, named Value (or whatever name you chose).Yeh, that was the only solution I saw as well. Thanks.