当前位置: 首页>>代码示例>>C#>>正文


C# System.Xml.XmlTextReader.MoveToContent方法代码示例

本文整理汇总了C#中System.Xml.XmlTextReader.MoveToContent方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlTextReader.MoveToContent方法的具体用法?C# System.Xml.XmlTextReader.MoveToContent怎么用?C# System.Xml.XmlTextReader.MoveToContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlTextReader的用法示例。


在下文中一共展示了System.Xml.XmlTextReader.MoveToContent方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadTemplate

 public static int LoadTemplate(ref string err, ref DataSet rmdb, string file)
 {
     DataTable rmdb_set = new DataTable("fields");
     rmdb_set.Columns.Add("id");
     rmdb_set.Columns.Add("type");
     rmdb_set.Columns.Add("value");
     try {
         System.Xml.XmlTextReader xmlReader = new System.Xml.XmlTextReader( file );
         string contents = "";
         while (xmlReader.Read()) {
             xmlReader.MoveToContent();
             string xmlId = null;
             string xmlType = null;
             string xmlValue = null;
             if (xmlReader.NodeType == System.Xml.XmlNodeType.Element) {
                 // contents += "ELEMENT <"+xmlReader.Name + ">\n";
                 if (xmlReader.HasAttributes) {
                     // contents += "Attributes of <" + xmlReader.Name + ">\n";
                     for (int i = 0; i < xmlReader.AttributeCount; i++) {
                         // contents += xmlReader[i];
                         if (i == 0)
                             xmlId = xmlReader[i];
                         if (i == 1)
                             xmlType = xmlReader[i];
                     }
                 }
             }
             if (xmlReader.NodeType == System.Xml.XmlNodeType.Text) {
                 //contents += "TEXT " + xmlReader.Value + "\n";
                 xmlValue = xmlReader.Value;
             }
             // populate internal database
             if (xmlId != null && xmlType != null) {
                 rmdb_set.Rows.Add(xmlId, xmlType, xmlValue);
                 Console.Write(xmlId, xmlType, xmlValue);
             }
         }
         Console.Write(contents);
         rmdb.Tables.Add(rmdb_set);
         return 0;
     }
     catch (Exception e) {
         err = e.Source.ToString() + ": " + e.Message.ToString();
         return 1;
     }
 }
开发者ID:greenpau,项目名称:RemedySync,代码行数:46,代码来源:remedysync.cs

示例2: GetEvalListFromArgs

    public static List<ReturnsEval.DataSeriesEvaluator> GetEvalListFromArgs(string[] argsList_)
    {
      List<ReturnsEval.DataSeriesEvaluator> list = new List<ReturnsEval.DataSeriesEvaluator>();

      foreach (string s in argsList_)
      {
        if (System.IO.Directory.Exists(s))
        {
          foreach (string path in System.IO.Directory.GetFiles(s))
          {
            ReturnsEval.DataSeriesEvaluator ev = ReturnsEval.DataSeriesEvaluator.ReadFromDisk(path);
            if (ev != null) list.Add(ev);
            KeyValuePair<ConstructGen<double>, ReturnsEval.DataSeriesEvaluator> kvp = ExtensionMethods.ReadFromDisk<KeyValuePair<ConstructGen<double>, ReturnsEval.DataSeriesEvaluator>>(path);
            if (kvp.Value != null) list.Add(kvp.Value);
          }
        }
        else if (System.IO.File.Exists(s))
        {
          if (s.EndsWith(".xml"))
          {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(string.Format(@"file://{0}", s.Replace(@"\", "/")));
            reader.MoveToContent();
            doc.Load(reader);
            reader.Close();
            foreach (System.Xml.XmlNode node in doc.DocumentElement.SelectNodes("BloombergTicker"))
            {
              DatedDataCollectionGen<double> hist = BbgTalk.HistoryRequester.GetHistory(new DateTime(2000, 1, 1), node.InnerText, "PX_LAST", true);
              DatedDataCollectionGen<double> genHist = new DatedDataCollectionGen<double>(hist.Dates, hist.Data).ToReturns();
              BbgTalk.RDResult nameData = BbgTalk.HistoryRequester.GetReferenceData(node.InnerText, "SHORT_NAME", null);
              ReturnsEval.DataSeriesEvaluator eval = new ReturnsEval.DataSeriesEvaluator(genHist.Dates, genHist.Data, nameData["SHORT_NAME"].GetValue<string>(), ReturnsEval.DataSeriesType.Returns);
              list.Add(eval);
            }
          }
          else
          {
            ReturnsEval.DataSeriesEvaluator ev = ReturnsEval.DataSeriesEvaluator.ReadFromDisk(s);
            if (ev != null) list.Add(ev);
            KeyValuePair<ConstructGen<double>, ReturnsEval.DataSeriesEvaluator> kvp = SI.ExtensionMethods.ReadFromDisk<KeyValuePair<ConstructGen<double>, ReturnsEval.DataSeriesEvaluator>>(s);
            if (kvp.Value != null) list.Add(kvp.Value);
          }
        }
      }

      return list;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:46,代码来源:EvalComparerControl.cs

示例3: LoadConfig

 public static int LoadConfig(ref string err, ref Hashtable settings, string file)
 {
     try {
         System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader( file );
         string contents = "";
         while (reader.Read()) {
             reader.MoveToContent();
             if (reader.NodeType == System.Xml.XmlNodeType.Element)
                 contents += "<"+reader.Name + ">\n";
             if (reader.NodeType == System.Xml.XmlNodeType.Text)
                 contents += reader.Value + "\n";
         }
         Console.Write(contents);
         return 0;
     }
     catch (Exception e) {
         err = e.Source.ToString() + ": " + e.Message.ToString();
         return 1;
     }
 }
开发者ID:greenpau,项目名称:RemedySync,代码行数:20,代码来源:remedysync.cs

示例4: mnuCheckForUpdate_Click

        //-----------------------------------
        // 最新バージョンのチェック
        // "Check for Update"
        //-----------------------------------
        private void mnuCheckForUpdate_Click(object sender, EventArgs e)
        {
            string MsgText = "";
            Version newVersion = null;
            string url = "";
            string dt = "";
            System.Xml.XmlTextReader reader;

            /*
             *	<?xml version="1.0" encoding="utf-8"?>
             *		<markdownsharpeditor>
             *		<version>1.2.1.0</version>
             *		<date>2013/06/18</date>
             *		<url>http://hibara.org/software/markdownsharpeditor/</url>
             *	</markdownsharpeditor>
             */
            string xmlURL = "http://hibara.org/software/markdownsharpeditor/app_version.xml";
            using (reader = new System.Xml.XmlTextReader(xmlURL))
            {
                reader.MoveToContent();
                string elementName = "";
                if ((reader.NodeType == System.Xml.XmlNodeType.Element) && (reader.Name == "markdownsharpeditor"))
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == System.Xml.XmlNodeType.Element)
                        {
                            elementName = reader.Name;
                        }
                        else
                        {
                            if ((reader.NodeType == System.Xml.XmlNodeType.Text) && (reader.HasValue))
                            {
                                switch (elementName)
                                {
                                    case "version":
                                        newVersion = new Version(reader.Value);
                                        break;
                                    case "url":
                                        url = reader.Value;
                                        break;
                                    case "date":
                                        dt = reader.Value;
                                        break;
                                }
                            }
                        }
                    }
                }
            }

            if (newVersion == null)
            {
                //Failed to get the latest version information.
                MsgText = Resources.ErrorGetNewVersion;
                MessageBox.Show(MsgText, Resources.DialogTitleError, MessageBoxButtons.OK, MessageBoxIcon.Question);
                return;
            }

            // get current version
            Version curVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            if (curVersion.CompareTo(newVersion) < 0)
            {	//"New version was found! Do you open the download site?";
                MsgText = "Update info: ver." + newVersion + " (" + dt + " ) \n" + Resources.NewVersionFound;
                if (DialogResult.Yes == MessageBox.Show(this, MsgText, Resources.DialogTitleQuestion, MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    System.Diagnostics.Process.Start(url);
                }
            }
            else
            {	// You already have the latest version of this application.
                MsgText = Resources.AlreadyLatestVersion + "\nver." + newVersion + " ( " + dt + " ) ";
                MessageBox.Show(MsgText, Resources.DialogTitleInfo, MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
        }
开发者ID:shunichi,项目名称:MarkDownSharpEditor,代码行数:79,代码来源:Form1.cs

示例5: loadXmlResultsFile

        private TreeNode loadXmlResultsFile(string filename)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(filename);
            reader.MoveToContent();
            doc.Load(reader);

            System.Xml.XmlElement validatorDataElement =
                doc.FirstChild as System.Xml.XmlElement;
            System.Xml.XmlElement target =
                validatorDataElement.GetElementsByTagName("Target").Item(0)
                as System.Xml.XmlElement;
            statusLabel1.Text =
                "Results from validating target: " +
                target.GetAttribute("friendlyName") + " / " +
                target.GetAttribute("uniqueDeviceName");

            return extractRootFromXmlElement(doc.DocumentElement.FirstChild as System.Xml.XmlElement);
        }
开发者ID:rvodden,项目名称:upnp-developertools-old,代码行数:19,代码来源:MainForm.cs

示例6: GetBuildStage

        private string GetBuildStage()
        {
            if (!controller.SelectedProject.Detail.IsConnected)
            { return string.Empty; }




            if (controller.SelectedProject.ProjectState != ProjectState.Building &&
                controller.SelectedProject.ProjectState != ProjectState.BrokenAndBuilding)
            { return controller.SelectedProject.Detail.ProjectDescription; }

            String currentBuildStage = controller.SelectedProject.Detail.CurrentBuildStage;
            if (currentBuildStage == null || currentBuildStage.Length == 0)
            { return string.Empty; }

            System.Text.StringBuilder SB = new System.Text.StringBuilder();
            System.IO.StringWriter BuildStage = new System.IO.StringWriter(SB);

            try
            {
                System.Xml.XmlTextReader XReader;
                System.Xml.XmlDocument XDoc = new System.Xml.XmlDocument();

                XDoc.LoadXml(controller.SelectedProject.Detail.CurrentBuildStage);
                XReader = new System.Xml.XmlTextReader(XDoc.OuterXml, System.Xml.XmlNodeType.Document, null);
                XReader.WhitespaceHandling = System.Xml.WhitespaceHandling.None;

                while (XReader.Read())
                {
                    XReader.MoveToContent();

                    if (XReader.AttributeCount > 0)
                    {
                        BuildStage.WriteLine("{0}  {1}", XReader.GetAttribute("Time"), XReader.GetAttribute("Data"));
                    }
                }
            }
            catch
            {
                BuildStage = new System.IO.StringWriter();
            }
            return BuildStage.ToString();
        }
开发者ID:Raylehnhoff,项目名称:CruiseControl.NET,代码行数:44,代码来源:MainForm.cs

示例7: GetBasic

 /// <summary>
 /// Gets basic event information.
 /// </summary>
 /// <param name="log">The event's log.</param>
 /// <param name="source">The event's source. Can be <c>null</c>.</param>
 /// <param name="eventId">The event's id. Can be <c>null</c>.</param>
 /// <returns><c>true</c> if subscription represents a basic event, <c>false</c> if not.</returns>
 public bool GetBasic(out string log, out string source, out int? eventId)
 {
     log = source = null;
     eventId = null;
     if (!string.IsNullOrEmpty(this.Subscription))
     {
         using (System.IO.MemoryStream str = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(this.Subscription)))
         {
             using (System.Xml.XmlTextReader rdr = new System.Xml.XmlTextReader(str))
             {
                 rdr.MoveToContent();
                 rdr.ReadStartElement("QueryList");
                 if (rdr.Name == "Query" && rdr.MoveToAttribute("Path"))
                 {
                     string path = rdr.Value;
                     if (rdr.MoveToElement() && rdr.ReadToDescendant("Select") && path.Equals(rdr["Path"], StringComparison.InvariantCultureIgnoreCase))
                     {
                         string content = rdr.ReadString();
                         System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(content,
                             @"\*(?:\[System\[(?:Provider\[\@Name='(?<s>[^']+)'\])?(?:\s+and\s+)?(?:EventID=(?<e>\d+))?\]\])",
                             System.Text.RegularExpressions.RegexOptions.IgnoreCase |
                             System.Text.RegularExpressions.RegexOptions.Compiled |
                             System.Text.RegularExpressions.RegexOptions.Singleline |
                             System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace);
                         if (m.Success)
                         {
                             log = path;
                             if (m.Groups["s"].Success)
                                 source = m.Groups["s"].Value;
                             if (m.Groups["e"].Success)
                                 eventId = Convert.ToInt32(m.Groups["e"].Value);
                             return true;
                         }
                     }
                 }
             }
         }
     }
     return false;
 }
开发者ID:hpie,项目名称:hpie,代码行数:47,代码来源:Trigger.cs

示例8: ProcessFiles

      /// <summary>
      /// This is the worker thread.
      /// </summary>
      /// <param name="stateInfo">Not used.</param>
      void ProcessFiles(object stateInfo)
      {

        System.Text.StringBuilder stb = null;

        while (_filesToProcess.Count > 0)
        {
          string fullfilename = _filesToProcess.Dequeue();
          try
          {
            string category = null;
            string name = null;
            DateTime creationTime = DateTime.MinValue;
            string description = string.Empty;

            System.Xml.XmlTextReader xmlReader = new System.Xml.XmlTextReader(fullfilename);
            xmlReader.MoveToContent();
            while (xmlReader.Read())
            {
              if (xmlReader.NodeType == System.Xml.XmlNodeType.Element && xmlReader.LocalName == "Category")
              {
                category = xmlReader.ReadElementString();
                name = xmlReader.ReadElementString("Name");
                creationTime = System.Xml.XmlConvert.ToDateTime(xmlReader.ReadElementString("CreationTime"), System.Xml.XmlDateTimeSerializationMode.Local);
                if (xmlReader.LocalName == "Description")
                  description = xmlReader.ReadElementString("Description");
                break;
              }
            }
            xmlReader.Close();

            AddFitFunctionEntry(category, name, creationTime, description, fullfilename);

          }
          catch (Exception ex)
          {
            if (stb == null)
              stb = new StringBuilder();

            stb.AppendLine(ex.ToString());
          }
        }

        if (stb != null)
        {
          Current.Console.WriteLine("Exception(s) thrown in " + this.GetType().ToString() + " during parsing of fit functions, details will follow:");
          Current.Console.WriteLine(stb.ToString());
        }
        _threadIsWorking = false;
      }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:54,代码来源:FitFunctionService.cs

示例9: DoDeserialize

        /// <summary>
        /// Load options.
        /// </summary>
        /// <param name="filePath">File name to load options from.</param>
        private void DoDeserialize(string filePath)
        {
            if (System.IO.File.Exists(filePath))
            {
                global::System.IO.FileStream fileStream = null;
                try
                {
                    fileStream = global::System.IO.File.OpenRead(filePath);
                    if (fileStream.Length > 5)
                    {
                        using (global::System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(fileStream))
                        {
                            try
                            {
                                reader.MoveToContent();

                                // read attributes
                                string valueE = reader.GetAttribute("errorCategoryVisible");
                                if (valueE != null)
                                    this.ErrorCategoryVisible = Boolean.Parse(valueE);

                                string valueW = reader.GetAttribute("warningCategoryVisible");
                                if (valueW != null)
                                    this.WarningCategoryVisible = Boolean.Parse(valueW);

                                string valueI = reader.GetAttribute("infoCategoryVisible");
                                if (valueI != null)
                                    this.InfoCategoryVisible = Boolean.Parse(valueI);

                                string valueF = reader.GetAttribute("filteredCategoryVisible");
                                if (valueF != null)
                                    this.FilteredCategoryVisible = Boolean.Parse(valueF);

                                while (reader.Read())
                                {
                                    switch (reader.NodeType)
                                    {
                                        case System.Xml.XmlNodeType.Element:
                                            {
                                                DeserializeElement(reader, reader.Name);
                                                break;
                                            }
                                    }
                                }
                            }
                            finally
                            {
                                fileStream = null;
                            }
                        }
                    }
                }
                finally
                {
                    if (fileStream != null)
                        fileStream.Dispose();
                }
            }
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:63,代码来源:ViewModelOptions.cs


注:本文中的System.Xml.XmlTextReader.MoveToContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。