XSD to XML conversion not contain all the fields

拜拜、爱过 提交于 2019-12-25 01:53:40

问题


I have a XSD file and when i try to conver this file using following code

   public XmlDocument GetXml(XmlDocument xsd, XmlQualifiedName rootElem)
      {
        var reader = XmlReader.Create(new StringReader(xsd.OuterXml),new XmlReaderSettings
        {
            DtdProcessing = DtdProcessing.Prohibit
        });

        XmlSchema schema = XmlSchema.Read(reader, null);
        var generator = new XmlSampleGenerator(schema, rootElem);
        generator.MaxThreshold = 1;

        var xmlStringBuilder = new StringBuilder();
        var writer = XmlWriter.Create(xmlStringBuilder);
        generator.WriteXml(writer);

        var resultXmlDoc = new XmlDocument();
        resultXmlDoc.LoadXml(xmlStringBuilder.ToString());
        BlankOutValues(resultXmlDoc.DocumentElement);
        return resultXmlDoc;
    }

under the applicant i am setting a node employeetype like

but while converting all the field which is not contain all the values

while converting this with online tool it is working fine any idea?

enter image description here

under the node Time At Employer we have 2 fields but in other end it looks like an attribute!

来源:https://stackoverflow.com/questions/58165908/xsd-to-xml-conversion-not-contain-all-the-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!