0

Is there a way to generate XML structure from C# class definition? Like "Edit/ Paste Special/ Paste XML as classes" in Visual Studio, but in other direction. For instance, from

public class Citizen
{
    [XmlAttribute]
    public int CountryId;
    [XmlElement]
    public Person Person;
}

get

<Citizen ContryId = "123">
    <Person>John Doe</Person>
</Citizen>

?

avj
  • 1,626
  • 1
  • 19
  • 23
  • 2
    https://learn.microsoft.com/en-us/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe – jazb Dec 13 '18 at 07:36
  • 1
    Copy and paste your xml and press Convert buttion => https://xmltocsharp.azurewebsites.net/ – er-sho Dec 13 '18 at 07:39
  • OK, thank you, I voted to close as duplicate. – avj Dec 13 '18 at 07:40
  • My spidey senses tell me there is an answer coming to this question very soon – TheGeneral Dec 13 '18 at 07:49
  • you did vote to close -you voted as useful comment. you need 3K+ to vote to close – jazb Dec 13 '18 at 07:49
  • It´s not a dupe on StackOverflow (although I´m convinced there are plenty of similar questions). Just delete the question. – MakePeaceGreatAgain Dec 13 '18 at 07:49
  • there must be a dup somewhere... – jazb Dec 13 '18 at 07:49
  • Yes, that's a correct dupe, not like the first one... – Zohar Peled Dec 13 '18 at 07:55
  • It is duplicate not of https://stackoverflow.com/questions/4123590/serialize-an-object-to-xml (see "class" - "object" difference ), but https://stackoverflow.com/questions/10017139/how-to-create-a-xsd-schema-from-a-class. – avj Dec 13 '18 at 07:56
  • And comment suggesting xlm to C# convertion is plainly contrary to direction asked in question (c# to xml) :D – avj Dec 13 '18 at 07:57
  • Removing "C#" from question title probably will make this question less visible in search – avj Dec 13 '18 at 07:59
  • I updated the dup-link. It was not clear to me if you wanted just the xml-**data**, or actually the xml-**schema**. Your example seemed like the former. – MakePeaceGreatAgain Dec 13 '18 at 08:11

0 Answers0