Hakan Axheim

Hakan Axheim

  • NA
  • 201
  • 32.4k

Serialize an XML file

Mar 4 2021 2:41 PM
Hi,
 
Need some help with an application that I am working with. It's a windows service that is an integration between two different systems. I am listening for events and when an event occur I receive an XML document.
 
I wan't to serialize that XML document into a C# class with DataContracts.
 
I have a problem with serializing that XML document because the XML document consists of a XML tag with name object.
  1. <object>  
  2. <id>1</id>  
  3. <name>NorthernLights</name>  
  4. </object>  
  1. public class object  
  2. {  
  3. [DataMember(IsRequired = true)]  
  4. public Guid Id { getset; }  
  5. [DataMember(IsRequired= false)]  
  6. public string name {getset; }  
  7. }  
I cannot create a class with name object so I wonder how to solve this?
 
I cannot change the XML document.

Answers (2)