return true if a Element is a Simple Type from XmlSchemaElement - CSharp System.Xml

CSharp examples for System.Xml:XML Element

Description

return true if a Element is a Simple Type from XmlSchemaElement

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;//from   w  w w  . jav  a 2 s  .co  m

public class Main{
        /// <summary>
        /// return true if a Element is a SimpleType
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public static bool IsSimpleType(XmlSchemaElement element)
        {
            if (element.ElementSchemaType is XmlSchemaSimpleType)
                return true;

            if (element.ElementSchemaType is XmlSchemaComplexType)
            {
                XmlSchemaComplexType complexType = (XmlSchemaComplexType)element.ElementSchemaType;
                if (complexType.ContentModel is XmlSchemaSimpleContent)
                    return true;
            }

            return false;
        }
}

Related Tutorials