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


C# XmlTextReader.ReadString方法代码示例

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


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

示例1: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack) //sürekli japon yeni ni ekliyodu butonda bu yüzden bunu ekledik sadece ilk postback olduğunda yapar sonraki postbackları yapmaz
        {
            ListItem aa;
            //ddlKurlar.Items.Add(new ListItem("japon yeni", "2,2")); 7/merkez bankasından xml alıcaz
            XmlTextReader re = new XmlTextReader("http://www.tcmb.gov.tr/kurlar/today.xml");
            string txt = "";
            string value = "";
            while (re.Read()) {

             if(re.NodeType==XmlNodeType.Element)

                 if (re.Name == "Isim") {

                     txt = re.ReadString();

                 }
             if (re.Name == "CrossRateUSD")
             {
                 value = re.ReadString();
                 if (value == "")
                     continue;  //boş değerleri böylece götürdük ddl deki
                 aa = new ListItem();
                 aa.Text = txt;
                 aa.Value = value.Replace(".", ",");
                 ddlKurlar.Items.Add(aa);
             }

            }
        }
    }
开发者ID:madmed,项目名称:netron,代码行数:32,代码来源:Default.aspx.cs

示例2: ReadXml

    private static string ReadXml(string filename, int ID)
    {
        string strLastVersion = "";

        XmlTextReader reader = new XmlTextReader(filename);

        while (reader.Read())
        {
            if (reader.HasAttributes)
            {
                while (reader.MoveToNextAttribute())
                {
                    if (reader.Name == "id")
                    {
                        if (reader.Value == ID.ToString())
                        {
                            strLastVersion = reader.ReadString();
                            reader.Close();
                            return strLastVersion;
                        }
                    }
                }
            }
        }

        return strLastVersion;
    }
开发者ID:Suplanus,项目名称:EplanElectricP8Automatisieren,代码行数:27,代码来源:02_XML-Datei_lesen.cs

示例3: ReadXML

    void ReadXML()
    {
        int typesCount = (int)MessageType.Count;
        messages = new List<string>[typesCount];
        for(int i = 0; i < typesCount; i++) {
            messages[i] = new List<string>();
        }

        XmlTextReader reader = new XmlTextReader (file.text, XmlNodeType.Element, null);
        while(reader.Read()) {
            string typeName = reader.Name;
            if(string.IsNullOrEmpty(typeName)) {
                continue;
            }

            string message = reader.ReadString();

            int mTypeIndex = (int)((MessageType)System.Enum.Parse(typeof(MessageType), typeName));
            if(mTypeIndex >= 0 && mTypeIndex < typesCount) {
                messages[mTypeIndex].Add(message);
        //				Debug.Log("Adding message: " + message + " for type " + typeName);
            } else {
                Debug.LogError("Unknown type " + typeName);
            }
        }
    }
开发者ID:PavelDrabek,项目名称:GoldDigger,代码行数:26,代码来源:MessageGenerator.cs

示例4: LoadXML

	void LoadXML()
	{
		file = Resources.Load("sprites/cfg/" + effect.name) as TextAsset;
		XmlTextReader reader = new XmlTextReader(new StringReader(file.text));		
		
		frame = 1;
		while(reader.Read())
			{
				switch (reader.Name)
					{
						case "x": 		x 		= float.Parse (reader.ReadString()); 	break;
						case "y": 		y 		= float.Parse (reader.ReadString()); 	break;
						case "offsetX": offsetX = float.Parse (reader.ReadString()); 	break;
						case "offsetY": offsetY = float.Parse (reader.ReadString()); 	break;
						case "no" : 	_frame 	= int.Parse(reader.ReadString()); if ( _frame == frame) { pos.Add(new coords(x, y, offsetX, offsetY)); frame++;} break;
					}	
			}
	}
开发者ID:joyfish,项目名称:tanks-vs-towers,代码行数:18,代码来源:sprites.cs

示例5: ReadLocale

    private void ReadLocale(XmlTextReader reader)
    {
        TransfluentUtility util = TransfluentUtility.GetInstance();

        while (reader.Read())
        {
            if (reader.IsStartElement())
            {
                //util.AddMessage("Start locale entry element: " + reader.Name);

                if (reader.Name.Equals("id"))
                {
                    string id = reader.ReadString();
                    if (!int.TryParse(id, out m_languageId))
                        util.AddError("Couldn't parse language id from '" + id + "'");
                }
                if (reader.Name.Equals("code"))
                    m_languageCode = reader.ReadString();
                if (reader.Name.Equals("name"))
                    m_languageName = reader.ReadString();
                if (reader.Name.Equals("texts"))
                    ReadTexts(reader);
            }
            else if (reader.Name.Equals("locale"))
            {
                // Done reading locale
                //util.AddMessage("End of locale");
                break;
            }
            else
                util.AddWarning("Unexpected element closed: " + reader.Name);
        }

        if (m_languageId == -1)
            util.AddError("Couldn't parse language id");
        if (m_languageCode == null)
            util.AddError("Couldn't parse language code");
        if (m_languageName == null)
            util.AddError("Couldn't parse language name");
        if (m_texts.Count == 0)
            util.AddWarning("No texts parsed or found");
    }
开发者ID:greendogs,项目名称:Transfluent-Unity,代码行数:42,代码来源:TransfluentLozalization.cs

示例6: GetMetaData

    public IList<string> GetMetaData(string xml)
    {
        IList<string> datasource = new List<string>();

        string VariableName = "";
        string SiteName = "";
        string UnitName = "";
        string latitude = "";
        string longitude = "";

        StringReader reader1 = new StringReader(xml);

        XmlTextReader reader = new XmlTextReader(reader1);

        using (reader)
        {
            while (reader.Read())
            {
                string readerName = reader.Name.ToLower();

                if (readerName == "variablename")
                {
                   VariableName = reader.ReadString();
                   datasource.Add(VariableName);
                }

                if (readerName == "sitename")
                {
                    SiteName = reader.ReadString();
                    datasource.Add(SiteName);
                }

                if (readerName == "latitude")
                {
                    latitude = reader.ReadString();
                    datasource.Add(latitude);
                }

                if (readerName == "longitude")
                {
                    longitude = reader.ReadString();
                    datasource.Add(longitude);
                }

                if (readerName == "unitname")
                {
                    UnitName = reader.ReadString();
                    datasource.Add(UnitName);
                }
                else if (readerName == "units")
                {
                    UnitName = reader.ReadString();
                    datasource.Add(UnitName);
                }
            }
            return datasource;
        }
    }
开发者ID:jirikadlec2,项目名称:hydrodata,代码行数:58,代码来源:XMLSerialization.cs

示例7: rss_update

    private void rss_update(object sender, EventArgs e)
    {
        int i;
        string title;
        int toggler = 1;
        try
        {
            led_line = "";
            reader = new XmlTextReader(url);
            using(reader)
            {
                reader.Read();
                reader.MoveToContent();
                i = 0;
                while(!reader.EOF)
                {
                    while(!reader.EOF && reader.Name != "item")
                        reader.Read();
                    while(!reader.EOF && reader.Name != "title")
                        reader.Read();
                    if(!reader.EOF)
                    {
                        title = reader.ReadString();
                        titles[i++] = title;
                        led_line += title+ " ";
                        if(toggler == 1)
                            led_line += "%r";
                        else
                            led_line += "%g";
                        toggler ^= 1;
                    }

                }
                num_titles = i;
            }

        }
        catch(Exception)
        {
            return;
        }
    }
开发者ID:elmo2k3,项目名称:mLedMatrix,代码行数:42,代码来源:RssPlugin.cs

示例8: SecenkListele

    private void SecenkListele( string xmlFileName)
    {
        List<Secenek> secenekler = new List<Secenek>();

        using (XmlTextReader reader = new XmlTextReader(Server.MapPath("~/App_Data/" + xmlFileName + ".xml")))
        {
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "secenek")
                {
                    secenekler.Add(new Secenek 
                    {
                        Name = xmlFileName,
                        Value = reader.ReadString() 
                    });
                }
            }

            gvwSecenek.DataSource = secenekler;
            gvwSecenek.DataBind();
        }
    }
开发者ID:ahmet-esmer,项目名称:asp.net-web-form-e-commerce,代码行数:22,代码来源:secenekler.aspx.cs

示例9: ReadXml

    private static string ReadXml(string filename, int id)
    {
        string lastVersion = string.Empty;
        XmlTextReader reader = new XmlTextReader(filename);
        while (reader.Read())
        {
            if (reader.HasAttributes)
            {
                while (reader.MoveToNextAttribute())
                {
                    if (reader.Name == "id")
                    {
                        if (reader.Value == id.ToString())
                        {
                            return lastVersion = reader.ReadString();
                        }
                    }
                }
            }
        }

        return lastVersion;
    }
开发者ID:nai-r-olf,项目名称:EplanScriptingProjectBySuplanus,代码行数:23,代码来源:GetProjectProperty.cs

示例10: GetDatabaseVersion

    } // End of the CreateXmlRow method

    /// <summary>
    /// Get the database version from an xml file
    /// </summary>
    /// <returns>The database version as an int</returns>
    public static Int32 GetDatabaseVersion()
    {
        // Create the int to return
        Int32 databaseVersion = 0;

        // Set the filename
        string filename = HttpContext.Current.Server.MapPath("/DatabaseFiles/DatabaseVersion.xml.gz");

        // Check if the file exists
        if (File.Exists(filename) == false)
            return databaseVersion;

        // Create variables
        GZipStream gzipStream = null;
        XmlTextReader xmlTextReader = null;

        try
        {
            // Create a gzip stream
            gzipStream = new GZipStream(new FileStream(filename, FileMode.Open), CompressionMode.Decompress);

            // Create a xml text reader
            xmlTextReader = new XmlTextReader(gzipStream);

            // Read the xml file
            while (xmlTextReader.Read())
            {
                // Get specific information
                if (xmlTextReader.Name == "Version")
                    Int32.TryParse(xmlTextReader.ReadString(), out databaseVersion);
            }

        }
        catch (Exception e)
        {
            throw e;
        }
        finally
        {
            // Close streams
            if (xmlTextReader != null)
            {
                // Close the XmlTextReader
                xmlTextReader.Close();
            }
            if (gzipStream != null)
            {
                // Close the gzip stream
                gzipStream.Close();
            }
        }

        // Return the database version
        return databaseVersion;

    } // End of the GetDatabaseVersion method
开发者ID:hunii,项目名称:a-blogsite,代码行数:62,代码来源:DatabaseManager.cs

示例11: Main

    public static void Main(string[] args) {

        if (args.Length != 3) {
            Console.WriteLine("Usage:genheaders XML-file header-file resorce-file");
            return;
        }
    
        ValidateXML(args[0]);
        String Message=null;
        String SymbolicName=null;
        String NumericValue=null;
        String tempheaderfile = "temp.h";
        String temprcfile = "temp.rc";

        StreamWriter HSW=File.CreateText(tempheaderfile);
        StreamWriter RSW=File.CreateText(temprcfile);

	int FaciltyUrt=0x13;
	int SeveritySuccess=0;
	int SeverityError=1;

	int minSR = MakeHresult(SeveritySuccess,FaciltyUrt,0);		
        int maxSR = MakeHresult(SeveritySuccess,FaciltyUrt,0xffff);	
	int minHR = MakeHresult(SeverityError,FaciltyUrt,0);		
	int maxHR = MakeHresult(SeverityError,FaciltyUrt,0xffff);		


        PrintHeader(HSW);  
        PrintResourceHeader(RSW);
        
        XmlTextReader rdr = new XmlTextReader(args[0]);
        rdr.WhitespaceHandling = WhitespaceHandling.None;
        
        while (rdr.Read()) {
            
            switch (rdr.NodeType) {           
                
                case XmlNodeType.Element:

                    if (rdr.Name.ToString() == "HRESULT") {
                        NumericValue=rdr.GetAttribute("NumericValue"); 			
                    }
                    if (rdr.Name.ToString() == "Message") {
                        Message = rdr.ReadString();
                    }
                    if (rdr.Name.ToString() == "SymbolicName") {    
                        SymbolicName = rdr.ReadString();
                    }
                
                    break;

                case XmlNodeType.EndElement:
                    if(rdr.Name.ToString() == "HRESULT"){

			// For CLR Hresult's we take the last 4 digits as the resource strings.

			if ( (NumericValue.StartsWith("0x")) || (NumericValue.StartsWith("0X")) ) {

			    String HexResult = NumericValue.Substring(2);
			    int num = int.Parse(HexResult, System.Globalization.NumberStyles.HexNumber);			    	

			    if ((num>minSR) && (num <= maxSR)) {
				num = num & 0xffff;
				HSW.WriteLine("#define " + SymbolicName + " SMAKEHR(0x" + num.ToString("x") + ")");
			    } else if ((num>minHR) && (num <= maxHR)) {
				num = num & 0xffff;
			        HSW.WriteLine("#define " + SymbolicName + " EMAKEHR(0x" + num.ToString("x") + ")");
			    } else {
              		        HSW.WriteLine("#define " + SymbolicName + " " + NumericValue );		
                            }  	 	


			    	
			} else {
	                    HSW.WriteLine("#define " + SymbolicName + " " + NumericValue );
			}

                        if (Message != null) {   
                            RSW.Write("\tMSG_FOR_URT_HR(" + SymbolicName + ") ");
                            RSW.WriteLine(Message);
                        } 

                        SymbolicName = null;
                        NumericValue = null;
                        Message = null;
                    }
                    break;

            }
        }

        PrintFooter(HSW);
        PrintResourceFooter(RSW);

        HSW.Close();
        RSW.Close();

        bool AreFilesEqual = false;

        if (File.Exists(args[1])) {
//.........这里部分代码省略.........
开发者ID:Rayislandstyle,项目名称:dotnet-coreclr,代码行数:101,代码来源:genheaders.cs

示例12: FromXmlString

		public override void FromXmlString(string xmlString)
		{
			StringReader input = new StringReader(xmlString);
			XmlTextReader xmlTextReader = new XmlTextReader(input);
			this.class14_0 = (this.class14_1 = (this.class14_2 = (this.class14_3 = (this.class14_4 = (this.class14_5 = (this.class14_6 = (this.class14_7 = null)))))));
			while (true)
			{
				XmlNodeType xmlNodeType = xmlTextReader.MoveToContent();
				XmlNodeType xmlNodeType2 = xmlNodeType;
				switch (xmlNodeType2)
				{
				case XmlNodeType.None:
					return;
				case XmlNodeType.Element:
				{
					string name = xmlTextReader.Name;
					if (!this.method_15(xmlTextReader, name, "Modulus", ref this.class14_0) && !this.method_15(xmlTextReader, name, "Exponent", ref this.class14_1) && !this.method_15(xmlTextReader, name, "P", ref this.class14_2) && !this.method_15(xmlTextReader, name, "Q", ref this.class14_3) && !this.method_15(xmlTextReader, name, "DP", ref this.class14_4) && !this.method_15(xmlTextReader, name, "DQ", ref this.class14_5) && !this.method_15(xmlTextReader, name, "InverseQ", ref this.class14_6) && !this.method_15(xmlTextReader, name, "D", ref this.class14_7))
					{
						xmlTextReader.ReadString();
					}
					break;
				}
				default:
					if (xmlNodeType2 != XmlNodeType.EndElement)
					{
						goto Block_9;
					}
					xmlTextReader.ReadEndElement();
					break;
				}
			}
			Block_9:
			throw new ArgumentException();
		}
开发者ID:akordowski,项目名称:Source-Code-Nitriq,代码行数:34,代码来源:Class1.cs

示例13: DisplayPathToExamples

    protected void DisplayPathToExamples()
    {
        try
        {
            XmlTextReader oXMLReader = null;
            oXMLReader = new XmlTextReader(Server.MapPath("examples.xml"));
            while (oXMLReader.Read())
            {
                if (oXMLReader.NodeType == XmlNodeType.Element && oXMLReader.Name == "path")
                {
                    lblPath.Text = "<b>Path to folder with Poll examples: </b>" + oXMLReader.ReadString();
                }
            }
            oXMLReader.Close();
        }
        catch (Exception ex)
        {
            if (ex != null) { ex = null; }
        }

        if (Request.QueryString["type"] != null)
        {
            ExamplesType.Value = Request.QueryString["type"].ToString();
        }
    }
开发者ID:veraveramanolo,项目名称:power-show,代码行数:25,代码来源:Default.aspx.cs

示例14: xmlparse

    // pseudo SAX reader
    public static void xmlparse(string fname)
    {
        XmlReader reader = new XmlTextReader(fname);
        string line;

        urls    =       new ArrayList();
        int cnt  = 0;
        // http://msdn.microsoft.com/en-us/library/1z92b1d4.aspx
        // http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.readsubtree.aspx
        while (reader.Read()) {
        if (reader.MoveToContent() == XmlNodeType.Element &&
            reader.Name == "formvals") {

            XmlReader inner = reader.ReadSubtree();
            StringDictionary myCol = new StringDictionary();
            while (inner.Read()) {

                if (inner.MoveToContent() == XmlNodeType.Element &&
                    inner.Name == "input") {

                    inner.MoveToFirstAttribute();
        // to avoid dependency on the attribute order, key them by the attribute name
        // amended with the unique count of the current input element.
                    myCol.Add(String.Format("{0}-{1}", inner.Name, cnt.ToString()), inner.Value);
                    inner.MoveToNextAttribute();
                    myCol.Add(String.Format("{0}-{1}", inner.Name, cnt.ToString()), inner.Value);
                    cnt++;
                }

                DictionaryEntry[] myArr = new DictionaryEntry[myCol.Count];
                myCol.CopyTo(myArr, 0);

                for (int i = 0; i < myArr.Length; i++) {

                    try{

                        string inputNameRegExp = @"name\-(?<input>\d+)";
                        MatchCollection myMatchCollection =
                            Regex.Matches(myArr[i].Key.ToString(), inputNameRegExp );

                        foreach (Match myMatch in myMatchCollection) {

                            string pos =  myMatch.Groups["input"].Value.ToString();
                            // do not use StringDictionary for final formvals or you have your keyc converted to lower case.
                            formvals.Add(myCol[String.Format("name-{0}", pos)], myCol[String.Format("value-{0}", pos)]);

                        }
                    } catch (Exception e) {
                        Console.WriteLine(e.ToString());
                    }

                }
                myCol.Clear();
            }
            foreach ( KeyValuePair<string, string> kvp in formvals )
                Console.WriteLine("formvals[ {0} ] = {1}", kvp.Key, kvp.Value);

            inner.Close();

        }
        if (reader.MoveToContent() == XmlNodeType.Element &&   reader.Name == "url") {
            line    =       reader.ReadString();
            urls.Add(line);
            Console.WriteLine(line);
        }
        }
    }
开发者ID:testpulse,项目名称:powershell_selenium,代码行数:68,代码来源:xparse.cs

示例15: ParseGetValues

    public IList<DataValues.DataValues> ParseGetValues(string xml)
    {
        IList<DataValues.DataValues> results = new List<DataValues.DataValues>();

        DataValues.DataValues val;

        StringReader reader1 = new StringReader(xml);

        XmlTextReader reader = new XmlTextReader(reader1);

        using (reader)
        {
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    string readerName = reader.Name.ToLower();

                    if (readerName == "value")
                    {
                        if (reader.HasAttributes)
                        {
                            val = new DataValues.DataValues();

                            //there may be an uppercase or a lowercase dateTime attribute
                            string localDateTime = reader.GetAttribute("dateTime");
                            if (string.IsNullOrEmpty(localDateTime))
                            {
                                localDateTime = reader.GetAttribute("DateTime");
                            }

                            string strVal = reader.ReadString();
                            if (strVal != "" && localDateTime != "")
                            {
                                val.LocalDateTime = Convert.ToDateTime(localDateTime, CultureInfo.InvariantCulture);
                                val.Value = Convert.ToDouble(strVal, CultureInfo.InvariantCulture);
                                results.Add(val);
                            }
                        }
                    }
                }
            }
            return results;

        }
    }
开发者ID:jirikadlec2,项目名称:hydrodata,代码行数:46,代码来源:XMLSerialization.cs


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