Get All Complex Types from the XML Schema. - CSharp System.Xml

CSharp examples for System.Xml:XML Schema

Description

Get All Complex Types from the XML Schema.

Demo Code


using System.Xml.Schema;
using System.Xml;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using System.Collections;
using System;// ww  w .  j  av a2s. co  m

public class Main{
        /// <summary>
        /// Get All Complex Types from the Schema.
        /// </summary>
        /// <param name="schema"></param>
        /// <returns></returns>
        public static List<XmlSchemaComplexType> GetAllComplexTypes(XmlSchema schema)
        {
            List<XmlSchemaComplexType> complexTypes = new List<XmlSchemaComplexType>();

            foreach (XmlSchemaObject item in schema.Items)
            {
                if (item is XmlSchemaComplexType) complexTypes.Add((XmlSchemaComplexType)item);
            }

            return complexTypes;
        }
}

Related Tutorials