c# - Deserializing child elements as attributes of parent -


I have XML files that I need to deserialize I use XSD tools from Visual Studio to create a C # object file. Generated Generated Classes destlicates files, except that the way I want to.

I would appreciate any help in finding out how to solve this problem.

The 'data' element should have the properties of 'work'.

A small example of XML is given below:

  & lt; Task type = "none" id = "2" TaskOnFail = "false" & gt; & Lt; Data value = "" name = "pre-test task" /> & Lt; Data value = "" name = "exclusion Task" /> & Lt; Data value = "" name = "approval restart" /> & Lt; Task type = "Wait for work" id = "10" taskOnFail = "false" & gt; & Lt; Data value = "" name = "pre-test task" /> & Lt; Data value = "" name = "exclusion Task" /> & Lt; Data value = "" name = "approval restart" /> & Lt; / Work & gt; & Lt; Task type = "Wait for work" id = "10" taskOnFail = "false" & gt; & Lt; Data value = "" name = "pre-test task" /> & Lt; Data value = "" name = "exclusion Task" /> & Lt; Data value = "" name = "approval restart" /> & Lt; / Work & gt; & Lt; / Work & gt;  

The definition of a class in which I am trying to deserialize, is in this form:

  public class works {public string prerequisites scops {get; Set;} Public String Exclusion Task {get; Set;} Repeat public string permissions {get; Set;} [System.Xml.Serialization.XmlElementAttribute ("Work")] Public List & Work; Work & gt; Child Task {get; Set;}} The child's work is fine, but the generated files place the 'data' elements in an array of data instead of [], instead of the designated members, 

If C can not deserialize generic lists, then what you need to do is define that normal How will the collection data be removed? To get one that you have got to implement GetObjectData (serialization information, streaming contact reference).

There is a sample code to help check out this article:


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -