c# - XML Serialization question - How to Serialize Element, Attribute and Text from One Object -


I am new to XML serialization using NIL and after working with it for some time now I am very disappointed is. I can sort the elements with the properties of other elements but I

  & lt; MyElement name = "foo" & gt; Bar & lt; / MyElement & gt;  

I use a class for my name with XmlAttribute for "name", but how to reference the XML element's value?

In advance thanks

, such as:

  Using the system; Using System.Xml.Serialization; [Serializable, XmlRoot ("My Element")] Public Class MyType {[XMLAttribute ("name")) Public string name {get; Set;} [xmltext] public string text {get; Set;}} Static class program {Static white main} (new XML serializer (typef (MyType)) Serialize (console.aut, new mytype {name = "afu", text = "bar"}); }}  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -