Home > Net >  The XML sequence of generic problem, online etc.! urgent
The XML sequence of generic problem, online etc.! urgent

Time:09-26

Have a XML files need to be deserialized to class, others can see the value attribute of XML containmentAttributes down through the namespace is divided into three kinds, should be written in the generics, now I don't know the corresponding classes should be how to write, strives for the great god,
 














The value of code I wrote the first
 
///& lt; Few/& gt;
[Serializable ()]
[System.Com ponentModel DesignerCategory (" code ")]
[System. Xml Serialization. XmlType (TypeName="DMPString AnonymousType=true, the Namespace=" http://www.hirain.com/dmp/1.0.0 ")]
//[System. Xml Serialization. XmlRoot (Namespace="http://www.Lincon.com/dmp/1.0.0")]
Public partial class containmentAttributesValue
{

Private string valueField;

///& lt; Few/& gt;
[System. Xml Serialization. XmlAttribute ()]
Public string value
{
The get
{
Return this. The valueField;
}
Set
{
Enclosing valueField=value;
}
}
}

CodePudding user response:

Don't sink ah, looking forward to the great god ~

CodePudding user response:

Try VS bring the function of the menu bar select edit - "paste special -" XML paste for the class

CodePudding user response:

 public static TData DeserializeFromXmlString (String data) 
{
Using (StringReader reader=new StringReader (data))
{
XmlSerializer serializer=new XmlSerializer (typeof (TData));
Return (TData) serializer. Deserialize (reader);
}
}

CodePudding user response:

 
Public class ContainmentAttributes
{
///& lt; Summary>
///
///& lt;/summary>
Public string - key {get; The set; }
}

Public class Devices
{
///& lt; Summary>
///
///& lt;/summary>
Public string - ID {get; The set; }
///& lt; Summary>
///platform management computer
///& lt;/summary>
Public string - Name {get; The set; }
///& lt; Summary>
///
///& lt;/summary>
Public string - lastModifier {get; The set; }
///& lt; Summary>
///
///& lt;/summary>
Public string - modifyTime {get; The set; }
///& lt; Summary>
///
///& lt;/summary>
Public string - shortName {get; The set; }
///& lt; Summary>
///
///& lt;/summary>
Public ContainmentAttributes ContainmentAttributes {get; The set; }
}

Public class Devices
{
///& lt; Summary>
///
///& lt;/summary>
Public string - ID {get; The set; }
///& lt; Summary>
///platform management computer
///& lt;/summary>
Public string - Name {get; The set; }
///& lt; Summary>
///
///& lt;/summary>
Public string - lastModifier {get; The set; }
///& lt; Summary>
///
///& lt;/summary>
Public string - modifyTime {get; The set; }
///& lt; Summary>
///
///& lt;/summary>
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • C#
  • Related