c# - XmlSerializer - Serialize elements without parent node -


This is my first question on stackoverflow, so it's going to be fun!

I got the following structure that I want to convert to XML. I need to include all the sub elements from the internal object, without the internal object as the node.

  square element 1 {element1.1 {element1.1.1, element.1.1.2, element.1.1.3, element1.1.4,}}   

In other words, how can I serialize the following?

  & lt; Element1 & gt; & Lt; Element1.1.1 / & gt; & Lt; Element1.1.2 / & gt; & Lt; Element1.1.3 / & gt; & Lt; Element1.1.4 / & gt; & Lt; / Element1>   

I am trying different combinations with XML, XML, etc., but they are still working.

Any word of advice would be deeply appreciated!

Here the code will be:

  [XmlElement ("Element1")] Public class Element1 {[XmlElement ("Element11")] Public string Element11 {get; Set; } [XmlElement ("element12")] Public element element 12 {get; Set;}} Public square element 12 {[XmlElement ("element121")) Public string element 1 {get; Set;} [XmlElement ("element122")] Public String (XML Element ("Element 123")) Public String Element 3 {get; Set;} [XmlElement ("element124")] public string element 4 {get; Set;}}    

You can not do this XmlSerializer creates the impression that the model you want to serial is the size of your XML roughly you can do some minor tweaks, but This is not one of them. If the problem is that your domain model has an additional layer, the solution is simple: Do not serialize your domain model For the purpose of XML serialization, one of the DTO classes The introduction of the new group which is completely , and change your data before it is sorted into the DTO model.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -