當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlTextReader.ReadContentAsString方法代碼示例

本文整理匯總了C#中System.Xml.XmlTextReader.ReadContentAsString方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlTextReader.ReadContentAsString方法的具體用法?C# XmlTextReader.ReadContentAsString怎麽用?C# XmlTextReader.ReadContentAsString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.XmlTextReader的用法示例。


在下文中一共展示了XmlTextReader.ReadContentAsString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Deserialize

        public void Deserialize(string str)
        {
            using (TextReader textReader = new StringReader(str))
            using (XmlReader xmlReader = new XmlTextReader(textReader))
            {
                xmlReader.ReadStartElement();

                xmlReader.ReadStartElement();
                this.Id = new Guid(xmlReader.ReadContentAsString());
                xmlReader.ReadEndElement();

                xmlReader.ReadStartElement();
                this.Value1 = xmlReader.ReadContentAsInt();
                xmlReader.ReadEndElement();

                xmlReader.ReadStartElement();
                this.Value2 = xmlReader.ReadContentAsDateTime();
                xmlReader.ReadEndElement();

                xmlReader.ReadStartElement();
                this.Value3 = xmlReader.ReadContentAsString();
                xmlReader.ReadEndElement();

                xmlReader.ReadStartElement();
                this.Value4 = xmlReader.ReadContentAsDecimal();
                xmlReader.ReadEndElement();

                xmlReader.ReadEndElement();
            }
        }
開發者ID:williams55,項目名稱:clinic-doctor,代碼行數:30,代碼來源:CustomXmlSerializable.cs

示例2: ReadToValue

        private static string ReadToValue(XmlTextReader reader)
        {
            while (reader.Read())
                if (reader.NodeType == XmlNodeType.Text)
                    break;

            return reader.ReadContentAsString();
        }
開發者ID:purplecow,項目名稱:Media-Browser,代碼行數:8,代碼來源:ITunesTrailerFolder.cs

示例3: Button1_Click

 protected void Button1_Click(object sender, EventArgs e)
 {
     XmlTextReader TR = new XmlTextReader("C:\\Users\\u\\Visual Studio 2013\\ejLeerXML\\ejLeerXML\\definicion.xml"); //Crea un XmlTextReader abriendo el archivo
     string ultimaEtiqueta = ""; //cadena que almacena la ultima etiqueta
     while (TR.Read()) //ciclo mientras XmlTextReader está leendo
     {
         if (TR.NodeType == XmlNodeType.Element) //condicional cuando lee un tipo elemento
         {
             txtlectura.Text += (new String(' ', TR.Depth * 3) + "<" + TR.Name + ">");
             ultimaEtiqueta = TR.Name;
             continue;
         }
         if (TR.NodeType == XmlNodeType.Text) //condicional cuando lee un tipo texto
         {
             txtlectura.Text += TR.ReadContentAsString() + "</" + ultimaEtiqueta + ">";
         }
         else //de lo contrario, será un salto de línea
             txtlectura.Text += "\r";
     }
 }
開發者ID:MacoChave,項目名稱:ejLeerXML,代碼行數:20,代碼來源:WebForm1.aspx.cs

示例4: LoadFromString

        public static DCompilerConfiguration LoadFromString(string xmlCode)
        {
            var cmp = new DCompilerConfiguration();

            var x = new XmlTextReader(new StringReader(xmlCode));

            if (x.ReadToFollowing("Compiler"))
            {
                if (x.MoveToAttribute("Name"))
                {
                    cmp.Vendor = x.ReadContentAsString();
                    x.MoveToElement();
                }

                cmp.ReadFrom(x);
            }

            x.Close();

            FitFileExtensions(cmp);

            return cmp;
        }
開發者ID:gavin-norman,項目名稱:Mono-D,代碼行數:23,代碼來源:PresetLoader.cs

示例5: ReadTextAsInt32

        public static int ReadTextAsInt32(string elemName, XmlTextReader reader)
        {
            int retVal = -1;
             string tmpString = null;
             reader.Read();
             if(reader.NodeType != XmlNodeType.Text) {
            Console.WriteLine( "ReadTextAsInt32(): <" + elemName + ">: kein Text gefunden!" );

             } else {
            try {
               tmpString = reader.ReadContentAsString();
               retVal = Convert.ToInt32( tmpString );
            } catch(Exception ex) {
               try {
                  bool tryBool = Convert.ToBoolean( tmpString );
                  retVal = Convert.ToInt32( tryBool );
               } catch(Exception) {

               }
               if(retVal == -1) {
                  Console.WriteLine( "ReadTextAsInt32(): <" + elemName + ">: " + ex );
                  throw ex;
               }
            }
             }
             return retVal;
        }
開發者ID:haefelic,項目名稱:Passwort-Encoder,代碼行數:27,代碼來源:TestEncoder.cs

示例6: ImportFiles

        private void ImportFiles(FileInfo f)
        {
            IndexList = new List<int>();
            GPXList = new List<GPXDatenSpeicher>();

            XmlTextReader xr = new XmlTextReader(f.FullName);
            #region Reader
            while (xr.Read())
            {
                if (Zustand == GPX_Zustände.START)
                {
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "gpx")
                    {
                        Zustand = GPX_Zustände.GPX;
                    }// ende if (xr.NodeType == XmlNodeType.Element && xr.Name == "gpx")
                }//ende if (Zustand == GPX_Zustände.START)
                else if (Zustand == GPX_Zustände.GPX)
                {
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "trk")
                    {
                        Zustand = GPX_Zustände.GPX_TRK;
                    }
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "wpt")
                    {
                        if (xr.HasAttributes)
                        {
                            while (xr.MoveToNextAttribute())
                            {
                                if (xr.Name == "lat") akt_lat = xr.ReadContentAsDouble();
                                if (xr.Name == "lon") akt_lon = xr.ReadContentAsDouble();
                            }
                        }
                        Zustand = GPX_Zustände.GPX_WPT;
                    }// ende if (xr.NodeType == XmlNodeType.Element && xr.Name == "wpt")

                } // ende else if (Zustand == GPX_Zustände.GPX)
                else if (Zustand == GPX_Zustände.GPX_TRK)
                {
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "name")
                    {
                        Zustand = GPX_Zustände.GPX_TRK_NAME;
                    }
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "trkseg")
                    {
                        Zustand = GPX_Zustände.GPX_TRK_TRKSEG;
                    }
                    if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "trk")
                    {
                        Zustand = GPX_Zustände.GPX;
                    }
                }// ende else if (Zustand == GPX_Zustände.GPX_TRK)
                else if (Zustand == GPX_Zustände.GPX_WPT)
                {
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "ele")
                    {
                        Zustand = GPX_Zustände.GPX_WPT_ELE;
                    }
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "name")
                    {
                        Zustand = GPX_Zustände.GPX_WPT_NAME;
                    }
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "cmt")
                    {
                        Zustand = GPX_Zustände.GPX_WPT_CMT;
                    }
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "desc")
                    {
                        Zustand = GPX_Zustände.GPX_WPT_DESC;
                    }
                    if (xr.NodeType == XmlNodeType.Element && xr.Name == "sym")
                    {
                        Zustand = GPX_Zustände.GPX_WPT_SYM;
                    }
                    if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "wpt")
                    {

                        SQL = "SELECT count(*) FROM tbl_Wegpunkt WHERE Längengrad like '" + akt_lon + "' AND Breitengrad like '" + akt_lat + "' AND Ele like '" + akt_ele + "' AND Name like '" + name + "' AND CMT like '" + cmt + "' AND DESC_Feld like '" + desc + "' AND sym like '" + sym + "'";
                        m.cmd = new OleDbCommand(SQL, m.con);
                        m.dr = m.cmd.ExecuteReader();
                        m.dr.Read();
                        if ((int)m.dr[0] == 0)
                        {
                            SQL = "INSERT INTO tbl_Wegpunkt (Längengrad,Breitengrad,Ele,Name,CMT,DESC_Feld,sym) VALUES ('" + akt_lon + "','" + akt_lat + "','" + akt_ele + "','" + name + "','" + cmt + "','" + desc + "','" + sym + "')";
                        }
                        m.cmd = new OleDbCommand(SQL, m.con);
                        m.cmd.ExecuteNonQuery();

                        Zustand = GPX_Zustände.GPX;
                    }
                }
                else if (Zustand == GPX_Zustände.GPX_WPT_ELE)
                {
                    strBuf = xr.ReadContentAsString().Replace('.', ',');
                    akt_ele = double.Parse(strBuf);
                    if (xr.NodeType == XmlNodeType.EndElement && xr.Name == "ele")
                    {
                        Zustand = GPX_Zustände.GPX_WPT;
                    }
                }
                else if (Zustand == GPX_Zustände.GPX_WPT_NAME)
//.........這裏部分代碼省略.........
開發者ID:xXLupoXx,項目名稱:GpxViewer,代碼行數:101,代碼來源:Import.cs

示例7: LoadHadeethTree

        /* Read all el 2a7dees al nabawaya and fill the treeview */
        private void LoadHadeethTree()
        {
            /* Check first if the tree was already loaded*/
            if (trvHadeeth.Nodes.Count > 0) return;

            XmlTextReader xmlReader;
            TreeNode rNode, bNode;

            for (int i = 0; i < 6; i++) {

                /* Check if the file exists first*/
                if (!File.Exists(hadeeth_xml[i])) continue;
                xmlReader = new XmlTextReader(hadeeth_xml[i]);
                xmlReader.ReadToFollowing("kotob");
                rNode = new TreeNode(xmlReader.GetAttribute(0));

                xmlReader.ReadToFollowing("katab");
                do {
                    xmlReader.MoveToFirstAttribute();
                    bNode = new TreeNode(xmlReader.ReadContentAsString());
                    xmlReader.MoveToElement();
                    if (xmlReader.ReadToDescendant("bab")) {
                        /* iterate through el babs in el katab if there are any */
                        do {
                            xmlReader.MoveToAttribute(0);
                            bNode.Nodes.Add(xmlReader.ReadContentAsString());
                        } while (xmlReader.ReadToNextSibling("bab"));
                    }
                    rNode.Nodes.Add(bNode);
                } while (xmlReader.ReadToFollowing("katab"));

                trvHadeeth.Nodes.Add(rNode);

            }
        }
開發者ID:yehiasalam,項目名稱:equran,代碼行數:36,代碼來源:Form1.cs

示例8: GetArchivedLogsUrls

		/// <summary>
		/// Parses the Log config file and extracts all archived logs.
		/// </summary>
		/// <returns>A Queue made of strings containing logs urls.</returns>
		public static Queue GetArchivedLogsUrls()
		{
			FileInfo info = new FileInfo(GameServer.Instance.Configuration.LogConfigFile);
			Queue dirList = new Queue();

			try
			{
				if (info.Exists)
				{
					Queue archiveList = new Queue(); // List made of all archived logs urls.

					// We parse the xml file to find urls of logs.
					XmlTextReader configFileReader = new XmlTextReader(info.OpenRead());
					configFileReader.WhitespaceHandling = WhitespaceHandling.None;
					while (configFileReader.Read())
					{
						if (configFileReader.LocalName == "file")
						{
							// First attribute of node file is the url of a Log.
							configFileReader.MoveToFirstAttribute();
							info = new FileInfo(configFileReader.ReadContentAsString());

							// Foreach file in the Log directory, we will return all logs with
							// the same name + an extension added when archived.
							foreach (string file in Directory.GetFiles(info.DirectoryName, info.Name + "*"))
							{
								// Only if this file is accessible we add it to the list we will return.
								if (file != info.FullName)
									archiveList.Enqueue(file);
							}
						}
					}
					return archiveList;
				}
				else
				{
					// We return the default value.
					Queue archiveList = new Queue(); // List made of all archived logs urls.
					archiveList.Enqueue("./logs/Cheats.Log");
					archiveList.Enqueue("./logs/GMActions.Log");
					archiveList.Enqueue("./logs/Error.Log");
					archiveList.Enqueue("./logs/GameServer.Log");
					return archiveList;
				}
			}
			catch (Exception e)
			{
				Logger.Error(e);
				return dirList;
			}
		}
開發者ID:mynew4,項目名稱:DAoC,代碼行數:55,代碼來源:MailMgr.cs

示例9: ReadXMLProgram

        //Read Program - This method must be refactored into DataSample
        private void ReadXMLProgram()
        {
            CurrentVO2MaxProgram = new VO2MaxProgram();
            string RootDiretory = AppDomain.CurrentDomain.BaseDirectory;
            XmlTextReader reader = null;

            switch (DataSample.ProgramSelector)
            {
                case Enumerators.ProgramSelect.VO2MaxProgram1:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\VO2MaxProgram1.xml");
                    lblTitle.Text = "Program: VO2 Max Program 1";
                    lblDescription.Text = "Program Time: 30 min";
                    CurrentPowerIndex = GlobalVariables.VO2MaxProgram1PB;
                    break;
                case Enumerators.ProgramSelect.VO2MaxProgram2:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\VO2MaxProgram2.xml");
                    lblTitle.Text = "Program: VO2 Max Program 2";
                    lblDescription.Text = "Program Time: 30 min";
                    CurrentPowerIndex = GlobalVariables.VO2MaxProgram2PB;
                    break;
                case Enumerators.ProgramSelect.VO2MaxProgram3:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\VO2MaxProgram3.xml");
                    lblTitle.Text = "Program: VO2 Max Program 3";
                    lblDescription.Text = "Program Time: 26 min";
                    CurrentPowerIndex = GlobalVariables.VO2MaxProgram3PB;
                    break;
                case Enumerators.ProgramSelect.VO2MaxProgram4:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\VO2MaxProgram4.xml");
                    lblTitle.Text = "Program: VO2 Max Program 4";
                    lblDescription.Text = "Program Time: 20 min";
                    CurrentPowerIndex = GlobalVariables.VO2MaxProgram4PB;
                    break;
                case Enumerators.ProgramSelect.CPM:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\CPMProgram.xml");
                    lblTitle.Text = "Program: Continuous Passive Motion (CPM)";
                    lblDescription.Text = "Program Time: 20 min";
                    CurrentPowerIndex = GlobalVariables.CPMProgramPB;
                    break;
                case Enumerators.ProgramSelect.Proprioception:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\ProprioceptionProgram.xml");
                    lblTitle.Text = "Program: Proprioception";
                    lblDescription.Text = "Program Time: 10 min";
                    CurrentPowerIndex = GlobalVariables.PropriocenptionProgramPB;
                    break;
                case Enumerators.ProgramSelect.RehabBilateral:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\ProgramRehabBilateral.xml");
                    lblTitle.Text = "Program: Rehabilitation - Bilateral (9 Stages)";
                    lblDescription.Text = "Program Time: 15 min";
                    CurrentPowerIndex = GlobalVariables.RehabProgramPB;
                    break;
                case Enumerators.ProgramSelect.RehabLeftLeg:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\ProgramRehabLeftLeg.xml");
                    lblTitle.Text = "Program: Rehabilitation - Left Leg (11 Stages)";
                    lblDescription.Text = "Program Time: 15 min";
                    CurrentPowerIndex = GlobalVariables.RehabProgramLeftPB;
                    break;
                case Enumerators.ProgramSelect.RehabRightLeg:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\ProgramRehabRightLeg.xml");
                    lblTitle.Text = "Program: Rehabilitation - Right Leg (11 Stages)";
                    lblDescription.Text = "Program Time: 15 min";
                    CurrentPowerIndex = GlobalVariables.RehabProgramRightPB;
                    break;
                //case Enumerators.ProgramSelect.CustomProgram:
                //    reader = new XmlTextReader(RootDiretory + "\\Programs\\ProgramRehabBilateral.xml");
                //    lblTitle.Text = "Program: Rehabilitation - Bilateral (9 Stages)";
                //    lblDescription.Text = "Program Time: 15 min";
                //    CurrentPowerIndex = GlobalVariables.RehabProgramPB;
                //    break;
                default:
                    break;
            }

            while (reader.Read())
            {
                if (reader.ReadToFollowing("StageIndex"))
                {
                    VO2MaxStage newVO2MaxStage = new VO2MaxStage();
                    reader.Read();
                    newVO2MaxStage.StageIndex = reader.ReadContentAsInt();
                    reader.ReadToFollowing("StageNumber");
                    reader.Read();
                    newVO2MaxStage.StageNumber = reader.ReadContentAsInt();
                    reader.ReadToFollowing("StageName");
                    reader.Read();
                    newVO2MaxStage.StageName = reader.ReadContentAsString();
                    reader.ReadToFollowing("StageDuration");
                    reader.Read();
                    newVO2MaxStage.StageTimeRemaining = new TimeSpan(0, reader.ReadContentAsInt(), 0);
                    reader.ReadToFollowing("Sets");
                    reader.Read();

                    while (reader.Read())
                    {
                        if (reader.Name == "Set")
                        {
                            VO2MaxSet newVO2MaxSet = new VO2MaxSet();
                            reader.ReadToFollowing("SetIndex");
                            reader.Read();
                            newVO2MaxSet.SetIndex = reader.ReadContentAsInt();
//.........這裏部分代碼省略.........
開發者ID:antonesterhuyse,項目名稱:GrucoxScrumView,代碼行數:101,代碼來源:frmVO2MaxPrograms.cs

示例10: LoadAllAssemblies

        // Загрузка всех сборок.
        public override List<ResultAssembly> LoadAllAssemblies()
        {
            List<ResultAssembly> assemblies = new List<ResultAssembly>();
            ResultAssembly assembly = null;

            foreach (string file in Directory.GetFiles(directory, "*.xml",
                SearchOption.TopDirectoryOnly))
            {
                assembly = new ResultAssembly();
                assemblies.Add(assembly);
                using (XmlTextReader reader = new XmlTextReader(file))
                {
                    try
                    {
                        reader.WhitespaceHandling = WhitespaceHandling.None;
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Element)
                            {
                                if (reader.Name == "id")
                                {
                                    assembly.ID = new Guid(reader.ReadElementString());
                                }
                                if (reader.Name == "name")
                                {
                                    assembly.Name = reader.ReadElementString();
                                }
                                if (reader.Name == "graphmodel")
                                {
                                    reader.MoveToAttribute("modelname");
                                    assembly.ModelName = reader.ReadContentAsString();
                                    break;
                                }
                                // !исправить!
                            }
                        }
                    }
                    catch (SystemException)
                    {
                        continue;
                    }
                }
            }

            return assemblies;
        }
開發者ID:kocharyan-ani,項目名稱:random_networks_explorer,代碼行數:47,代碼來源:XMLResultStorage.cs

示例11: LoadAarExplodeCache

        /// <summary>
        /// Load data cached in aarExplodeDataFile into aarExplodeData.
        /// </summary>
        private void LoadAarExplodeCache()
        {
            if (!File.Exists(aarExplodeDataFile)) return;

            XmlTextReader reader = new XmlTextReader(new StreamReader(aarExplodeDataFile));
            aarExplodeData.Clear();
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "aars")
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element && reader.Name == "explodeData")
                        {
                            string aar = "";
                            AarExplodeData aarData = new AarExplodeData();
                            do
                            {
                                if (!reader.Read()) break;
                                if (reader.NodeType == XmlNodeType.Element)
                                {
                                    string elementName = reader.Name;
                                    if (reader.Read() && reader.NodeType == XmlNodeType.Text)
                                    {
                                        if (elementName == "aar")
                                        {
                                            aar = reader.ReadContentAsString();
                                        }
                                        else if (elementName == "modificationTime")
                                        {
                                            aarData.modificationTime =
                                                reader.ReadContentAsDateTime();
                                        }
                                        else if (elementName == "explode")
                                        {
                                            aarData.explode = reader.ReadContentAsBoolean();
                                        }
                                        else if (elementName == "bundleId")
                                        {
                                            aarData.bundleId = reader.ReadContentAsString();
                                        }
                                        else if (elementName == "path")
                                        {
                                            aarData.path = reader.ReadContentAsString();
                                        }
                                    }
                                }
                            } while (!(reader.Name == "explodeData" &&
                                       reader.NodeType == XmlNodeType.EndElement));
                            if (aar != "") aarExplodeData[aar] = aarData;
                        }
                    }
                }
            }
        }
開發者ID:OvertimeStudios,項目名稱:CreepyBuster,代碼行數:58,代碼來源:ResolverVer1_1.cs

示例12: LoadFromXml

		public static SystemConfig LoadFromXml(Stream stream, bool isEncrypted)
		{
			if (stream == null)
			{
				throw new ArgumentNullException("stream");
			}

			using (XmlTextReader reader = new XmlTextReader(stream))
			{
				if (reader != null)
				{
					SystemConfig config = new SystemConfig();
					while (reader.Read())
					{
						if (reader.NodeType == XmlNodeType.Element && reader.Name == XmlElementConfig)
						{
							reader.MoveToAttribute(XmlAttribute);
							string attribute = reader.ReadContentAsString();
							switch (attribute)
							{
								case "MaxConnectionCount":
									reader.MoveToAttribute(XmlValue);
									config._maxConnectionCount = (ushort)reader.ReadContentAsInt();
									break;
                                case "AdminServerListenIP":
                                    reader.MoveToAttribute(XmlValue);
                                    config._adminServerListenIP = reader.ReadContentAsString();
                                    break;
								case "AdminServerListenPort":
									reader.MoveToAttribute(XmlValue);
									config._adminServerListenPort = reader.ReadContentAsInt();
									break;                                
								case "SecondaryAdminServerListenPort":
									reader.MoveToAttribute(XmlValue);
									config._secondaryAdminServerListenPort = reader.ReadContentAsInt();
									break;
								case "AdminServerUploadFileRootPath":
									reader.MoveToAttribute(XmlValue);
									config._adminServerUploadFileRootPath = reader.ReadContentAsString();

                                    if (!config._adminServerUploadFileRootPath.EndsWith(@"\")) config._adminServerUploadFileRootPath += @"\";

                                    //若該文件夾不存在,則創建它
                                    if (Directory.Exists(config._adminServerUploadFileRootPath) == false)
                                    {
                                        Directory.CreateDirectory(config._adminServerUploadFileRootPath);
                                    }

									break;
								case "DbConnectionString":
									{
										reader.MoveToAttribute(XmlValue);
										string readConnectionString = reader.ReadContentAsString();
										if (isEncrypted)
										{
											try
											{
												config._dbConnectionString = CryptographyManager.TheInstance.PredefinedDecrypt(readConnectionString, Encoding.Default);
											}
											catch (Exception ex)
											{
												throw new Exception("Decrypt SystemConfig Entry \"DbConnectionString\" Failed.", ex);
											}
										}
										else
										{
											config._dbConnectionString = readConnectionString;
										}
									}
									break;
								case "DefaultDbName":
									reader.MoveToAttribute(XmlValue);
									config._defaultDbName = reader.ReadContentAsString();
									break;
								case "DefaultEncoding":
									reader.MoveToAttribute(XmlValue);
									config._defaultEncoding = Encoding.GetEncoding(reader.ReadContentAsString());
									break;
								case "DefaultNewLine":
									{
										reader.MoveToAttribute(XmlValue);
										string newLine = reader.ReadContentAsString();
										if (newLine == @"\n")
										{
											config._defaultNewLine = "\n";
										}
										else if (newLine == @"\r\n")
										{
											config._defaultNewLine = "\r\n";
										}
									}
									break;
								case "LogDir":
									reader.MoveToAttribute(XmlValue);
									config._logDir = reader.ReadContentAsString();

                                    if (!config._logDir.EndsWith(@"\")) [email protected]"\";

                                    //若該文件夾不存在,則創建它
                                    if (Directory.Exists(config._logDir) == false)
//.........這裏部分代碼省略.........
開發者ID:viticm,項目名稱:pap2,代碼行數:101,代碼來源:SystemConfig.cs

示例13: ParseXML

        public static Element ParseXML(Stream xmlStream)
        {
            StreamReader textReader = new StreamReader(xmlStream);
            string responseString = "";
            while (!textReader.EndOfStream)
                responseString += textReader.ReadLine();

            StringReader stringReader = new StringReader(responseString);
            
            XmlTextReader reader = new XmlTextReader(stringReader);

#if DEBUG
            Console.Out.WriteLine("Original XML:");
            responseString = responseString.Replace(">", ">\n");
            Console.Out.WriteLine(responseString);
            Console.Out.WriteLine("");
#endif
            Element rootNode = new Element();
            rootNode.IsRootNode = true;
            //int lastDepth = -1;
            try
            {
                Stack<Element> stack = new Stack<Element>();
                
                stack.Push(rootNode);

                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element:
                            Element newElement = new Element();
                            newElement.Name = reader.Name;
                            newElement.Parent = stack.Peek();
                            stack.Peek().AddChildElement(newElement);
                            while (reader.MoveToNextAttribute())
                            {
                                Libellus.XML.Attribute a = new Libellus.XML.Attribute();
                                a.Name = reader.Name;
                                a.Value = reader.ReadContentAsString();
                                newElement.Attributes.Add(a);
                            }
                            if(!newElement.Name.Equals("Price"))
                                stack.Push(newElement);

                            break;

                        case XmlNodeType.Text:
                            stack.Peek().Value = reader.Value;
                            break;

                        case XmlNodeType.EndElement:
                            stack.Pop();
                            break;

                       
                    }
                }

                
            }
            catch (Exception e1)
            {
                ExceptionHandler.HandleException(e1);
            }

            return rootNode;
        }
開發者ID:antmason,項目名稱:libelluspersonallibrary,代碼行數:68,代碼來源:XMLParser.cs

示例14: ReadXMLProgram

        //Read Program
        public ProgramData ReadXMLProgram()
        {
            ProgramData CurrentProgram = new ProgramData();
            string RootDiretory = AppDomain.CurrentDomain.BaseDirectory;
            string appPath = Path.GetDirectoryName(Application.ExecutablePath);
            XmlTextReader reader = null;

            switch (this.ProgramSelector)
            {
                case Enumerators.ProgramSelect.FTPTest:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\FTPTestConcentric.xml");
                    break;
                case Enumerators.ProgramSelect.VO2MaxTest:
                    reader = new XmlTextReader(RootDiretory + "\\Programs\\VO2MaxTest.xml");
                    break;
                default:
                    break;
            }

            while (reader.Read())
            {
                if (reader.ReadToFollowing("StageIndex"))
                {
                    ProgramStage newFTPStage = new ProgramStage();
                    reader.Read();
                    newFTPStage.StageIndex = reader.ReadContentAsInt();
                    reader.ReadToFollowing("StageNumber");
                    reader.Read();
                    newFTPStage.StageNumber = reader.ReadContentAsInt();
                    reader.ReadToFollowing("StageName");
                    reader.Read();
                    newFTPStage.StageName = reader.ReadContentAsString();
                    reader.ReadToFollowing("StageDuration");
                    reader.Read();
                    newFTPStage.StageTimeRemaining = new TimeSpan(0, reader.ReadContentAsInt(), 0);
                    reader.ReadToFollowing("Sets");
                    reader.Read();

                    while (reader.Read())
                    {
                        if (reader.Name == "Set")
                        {
                            ProgramSet newFTPSet = new ProgramSet();
                            reader.ReadToFollowing("SetIndex");
                            reader.Read();
                            newFTPSet.SetIndex = reader.ReadContentAsInt();
                            reader.ReadToFollowing("Number");
                            reader.Read();
                            newFTPSet.SetNumber = reader.ReadContentAsInt();
                            reader.ReadToFollowing("Duration");
                            reader.Read();
                            newFTPSet.TimeRemaining = new TimeSpan(0, reader.ReadContentAsInt(), 0);
                            reader.ReadToFollowing("Direction");
                            reader.Read();
                            newFTPSet.Direction = reader.ReadContentAsString();
                            reader.ReadToFollowing("DirectionFlag");
                            reader.Read();
                            int DirectionVariable = reader.ReadContentAsInt();
                            if (DirectionVariable == 1)
                                newFTPSet.SelectedDirection = Enumerators.Direction.Forward;
                            else if (DirectionVariable == -1)
                                newFTPSet.SelectedDirection = Enumerators.Direction.Backward;
                            reader.ReadToFollowing("Contraction");
                            reader.Read();
                            newFTPSet.Contraction = reader.ReadContentAsString();
                            reader.ReadToFollowing("Legs");
                            reader.Read();
                            newFTPSet.Legs = reader.ReadContentAsString();
                            reader.ReadToFollowing("Position");
                            reader.Read();
                            newFTPSet.Position = reader.ReadContentAsString();
                            reader.ReadToFollowing("RestDuration");
                            reader.Read();
                            newFTPSet.RestTimeRemaining = new TimeSpan(0, reader.ReadContentAsInt(), 0);
                            reader.ReadToFollowing("Instructions");
                            reader.Read();
                            newFTPSet.Instructions = reader.ReadContentAsString();
                            newFTPStage.FTPSetConcentricCollection.Add(newFTPSet);

                            reader.Read();  //Read White Space
                            reader.Read();  //Read Set
                            reader.Read();  //Read White Space

                        }
                        else
                        {
                            break;
                        }
                    }
                    CurrentProgram.FTPStageCollection.Add(newFTPStage);
                }
            }

            CurrentProgram.CurrentFTPStage = CurrentProgram.FTPStageCollection[0];
            CurrentProgram.CurrentFTPStage.CurrentFTPSet = CurrentProgram.CurrentFTPStage.FTPSetConcentricCollection[0];
            return CurrentProgram;
        }
開發者ID:antonesterhuyse,項目名稱:GrucoxScrumView,代碼行數:98,代碼來源:objDataSample.cs

示例15: getChosenElement

 public string getChosenElement(XmlTextReader xml, string element)
 {
     string content;
     try
     {
         xml.ReadStartElement(element);
         content = xml.ReadContentAsString();
         xml.ReadEndElement();
     }
     catch (XmlException e)
     {
         content = null;
     }
     return content;
 }
開發者ID:dineshkummarc,項目名稱:SWAT_4.1_Binaries_Source,代碼行數:15,代碼來源:DDEditor.cs


注:本文中的System.Xml.XmlTextReader.ReadContentAsString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。