Answers for "c# generate xml from xsd at runtime"

C#
0

c# generate xml from xsd at runtime

public XmlDocument GenerateEmptyPdfTemplate(GenerateEmptyPdfTemplateDto generateEmptyPdfTemplateDto)
{
  XmlDocument doc = new XmlDocument();

  XmlSchemaSet schemaSet = new XmlSchemaSet();
  // generateEmptyPdfTemplateDto.XsdDocument <--string xsd
  schemaSet.Add(null, XmlReader.Create(new StringReader(generateEmptyPdfTemplateDto.XsdDocument)));

  schemaSet.Compile();


  XmlSampleGenerator generator = new XmlSampleGenerator(schemaSet, new XmlQualifiedName("foo"));
  generator.MaxThreshold=1;
  doc = new XmlDocument();
  using (XmlWriter writer = doc.CreateNavigator().AppendChild())
  {
    generator.WriteXml(writer);
  }

  return doc;
}
Posted by: Guest on September-30-2020

C# Answers by Framework

Browse Popular Code Answers by Language