Esempio n. 1
0
        ///
        /// <summary> Read the XML file into memory </summary>
        ///
        public void ReadXml(XmlReader r, string fileNameWithourExtension)
        {
            //Skip the XML declaration
            r.MoveToContent();
            //Read the start tag of root element
            r.ReadStartElement(_elementName);
            r.MoveToContent();

            Observation elmt = new Observation();

            _datasource.Columns.Add(elmt.DateName, typeof(DateTime));
            _datasource.Columns.Add(fileNameWithourExtension, typeof(double));
            _datasource.PrimaryKey = new DataColumn[] { _datasource.Columns[elmt.DateName] };

            while (r.NodeType == XmlNodeType.Element)
            {
                //Check if Observation has value. If yes, add it to the list.
                if (elmt.ReadXML(r))
                {
                    _datasource.Rows.Add(elmt.Date, elmt.Value);
                    //_observations.Add(elmt.Date, elmt.Value);
                }
            }
            r.ReadEndElement();
        }