System.Data.DataSet.InferXmlSchema C# (CSharp) Method

InferXmlSchema() public method

Infer the XML schema from the specified into the .
public InferXmlSchema ( XmlReader reader, string nsArray ) : void
reader XmlReader
nsArray string
return void
        public void InferXmlSchema(XmlReader reader, string[] nsArray)
        {
            long logScopeId = DataCommonEventSource.Log.EnterScope("<ds.DataSet.InferXmlSchema|API> {0}", ObjectID);
            try
            {
                if (reader == null)
                {
                    return;
                }

                XmlDocument xdoc = new XmlDocument();
                if (reader.NodeType == XmlNodeType.Element)
                {
                    XmlNode node = xdoc.ReadNode(reader);
                    xdoc.AppendChild(node);
                }
                else
                {
                    xdoc.Load(reader);
                }

                if (xdoc.DocumentElement == null)
                {
                    return;
                }

                InferSchema(xdoc, nsArray, XmlReadMode.InferSchema);
            }
            finally
            {
                DataCommonEventSource.Log.ExitScope(logScopeId);
            }
        }

Same methods

DataSet::InferXmlSchema ( Stream stream, string nsArray ) : void
DataSet::InferXmlSchema ( TextReader reader, string nsArray ) : void
DataSet::InferXmlSchema ( string fileName, string nsArray ) : void

Usage Example

		public void SimpleLoad ()
		{
			string xml001 = "<root/>";
			XmlDataDocument doc = new XmlDataDocument ();
			DataSet ds = new DataSet ();
			ds.InferXmlSchema (new StringReader (xml001), null);
			doc.LoadXml (xml001);

			string xml002 = "<root><child/></root>";
			doc = new XmlDataDocument ();
			ds = new DataSet ();
			ds.InferXmlSchema (new StringReader (xml002), null);
			doc.LoadXml (xml002);

			string xml003 = "<root><col1>test</col1><col1></col1></root>";
			doc = new XmlDataDocument ();
			ds = new DataSet ();
			ds.InferXmlSchema (new StringReader (xml003), null);
			doc.LoadXml (xml003);

			string xml004 = "<set><tab1><col1>test</col1><col1>test2</col1></tab1><tab2><col2>test3</col2><col2>test4</col2></tab2></set>";
			doc = new XmlDataDocument ();
			ds = new DataSet ();
			ds.InferXmlSchema (new StringReader (xml004), null);
			doc.LoadXml (xml004);
		}
All Usage Examples Of System.Data.DataSet::InferXmlSchema