I have an xml file.i need to serialize to c# class.
<Configs>
<Services>
<Path>
<Url>test</Url>
<ID>1234</ID>
</Path>
<Path>
<Url>java</Url>
<ID>1234</ID>
</Path>
</Services>
<Certification>
<name>Mark</name>
<name>Peter</name>
</Certification>
</Configs>
</Configuration>
I need to serialize this into a class
I have written the following class.
public class Configuration
{
public Certification Configs { get; set; }
public Path[] Services { get; set; }
}
public class Certification
{
[XmlArray("Certification")]
[XmlArrayItem("name")]
public string[] name { get; set; }
}
public class Path
{
public string Url { get; set; }
public string ID { get; set; }
}
I am getting the value of Certification class and its value.
I created an object for Configuration and looped
foreach (string Name in obj.Configs.name)
{
}
this is working.
But i am not getting the value of Services.
This is not working getting null on obj.services
Foreach (Path serviceUrl in obj.Services)
{
}
obj.Services is null
How to get the value of url and ID node in Path?
Thanks
Your
Servicesarray is in the wrong class. It should be inside theConfigsproperty of the root class: