You must Sign In to post a response.
  • Category: XML

    How to Read XSD values into text file using .NET?

    Are you looking for a way to Read XSD values into text file using .NET? then read this thread to know how to read it


    My sample XSD is like below, now I want to read this simpletype values and display into one text file. I did maximum part but I'm unable to complete this union case. Can anybody help me to clear this.

    <xs:simpleType name="file-number">
    <xs:restriction base="xs:integer">
    <xs:totalDigits value="3"/>
    <xs:minInclusive value="1"/>
    <xs:maxInclusive value="999"/>
    <xs:restriction base="xs:string">
    <xs:whiteSpace value="preserve"/>
    <xs:enumeration value=""/>

  • #746119
    Can you post your existing solution code so I can suggest the necessary changes required to handle union element.


  • #746541
    Hai Naveen,
    The XSD file is also one type of XML file so you can use the same code which i used to read the XML file.
    You can read the specif node and then get all the decedent nodes of it and display it.
    Below code can be helpful to you:

    string xsdFile="<xs:simpleType name="file-number"><xs:union><xs:simpleType><xs:restriction base="xs:integer"><xs:totalDigits value="3"/>
    <xs:minInclusive value="1"/><xs:maxInclusive value="999"/></xs:restriction></xs:simpleType><xs:simpleType><xs:restriction base="xs:string">
    <xs:whiteSpace value="preserve"/><xs:enumeration value=""/>
    var document = XDocument.Load(xsdFile);
    var nodes = document.Descendents().Where(e => e.Name.LocalName.StartsWith("xs:simpleType"));
    foreach(var node in nodes)
    // get the node values one by one here

    Hope it will be helpful to you.

    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)

  • Sign In to post your comments