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


C# XmlTextReader.Read方法代码示例

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


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

示例1: GetDialogById

    public List<string> GetDialogById(string id)
    {
        XmlTextReader reader = new XmlTextReader(XMLFileName);
        List<string> texts   = new List<string>();

        while (reader.Read())
        {
            if (reader.NodeType == XmlNodeType.Element && reader.Name == id)
            {
                int i = 0;
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.EndElement && reader.Name == id)
                    {
                        break;
                    }
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == ("text_" + i))
                    {
                        texts.Add(reader.ReadElementContentAsString());
                        i++;
                    }
                }
            }
        }
        reader.Close();

        return texts;
    }
开发者ID:AlexanderMekumyanov,项目名称:SerKnight,代码行数:28,代码来源:DialogSystem.cs

示例2: readXML

    private void readXML()
    {
        string fileName = "/home/nasser/Desktop/ncg/ncg/sampledata.xml";
        if (File.Exists (fileName)) {

            XmlTextReader xreader = new XmlTextReader(fileName);
            label1.Text="";
            while(xreader.Read ())
            {
                if(xreader.NodeType==XmlNodeType.Element)
                {
                    xreader.Read();
                    if(xreader.NodeType==XmlNodeType.Text)
                    {
                    }
                }
                /*label1.Text+="\nnode type :\t"+xreader.NodeType.ToString ();
                label1.Text+="\nname : \t\t"+xreader.Name;
                label1.Text+="\nvalue :\t\t"+xreader.Value;
                label1.Text+="\n-----------------";*/
            }

            //label1.Text+="\n"+xreader.GetAttribute("version").ToString ();
        }
        else
            label1.Text="file not exists";
    }
开发者ID:nasserman,项目名称:ngc,代码行数:27,代码来源:MainWindow.cs

示例3: ReadXml

    public static List<string> ReadXml(string path, string colum)
    {
        List<string> listOfElements = new List<string>();

        XmlTextReader textReader = new XmlTextReader(path);

        int foundName = 0;

        while (textReader.Read())
        {
            if (foundName > 0 && textReader.Name != string.Empty && !String.Equals(textReader.Name, colum, StringComparison.CurrentCultureIgnoreCase))
                foundName = 0;

            if (foundName == 2 && String.Equals(textReader.Name, colum, StringComparison.CurrentCultureIgnoreCase))
            {
                foundName = 0; continue;
            }

            if (foundName == 0 && String.Equals(textReader.Name, colum, StringComparison.CurrentCultureIgnoreCase))
            {
                foundName = 1; continue;
            }

            if (foundName != 1 || textReader.Name != string.Empty) continue;

            listOfElements.Add(textReader.Value);
        }

        textReader.Close();
        return listOfElements;
    }
开发者ID:nelsonjma,项目名称:siebel_log_notepad,代码行数:31,代码来源:read_xml.cs

示例4: Read

 public static void Read()
 {
     XmlTextReader reader = new XmlTextReader("books.xml");
     while (reader.Read())
     {
         switch (reader.NodeType)
         {
             case XmlNodeType.Element: // The node is an element.
                 Console.Write("<" + reader.Name);
                 while (reader.MoveToNextAttribute()) // Read the attributes.
                     Console.Write(" " + reader.Name + "='" + reader.Value + "'");
                 Console.WriteLine(">");
                 break;
             case XmlNodeType.Text: //Display the text in each element.
                 Console.WriteLine (reader.Value);
                 break;
             case XmlNodeType. EndElement: //Display the end of the element.
                 Console.Write("</" + reader.Name);
                 Console.WriteLine(">");
             break;
         }
     }
     // Do some work here on the data.
     Console.ReadLine();
 }
开发者ID:walrus7521,项目名称:code,代码行数:25,代码来源:Xml.cs

示例5: GetTargetNamespace

	public static string GetTargetNamespace (string src)
	{
		XmlTextReader reader = null;
		try
		{
			reader = new XmlTextReader (src);
			reader.WhitespaceHandling = WhitespaceHandling.None;
			while (reader.Read())
			{
				if (reader.NodeType == XmlNodeType.Element &&
				reader.LocalName == "schema")
				{
					while (reader.MoveToNextAttribute ())
					{
						if (reader.Name == "targetNamespace")
							return reader.Value;
					}
				}
			}
			return "";
		}	
		finally 
		{
			if (reader != null)
				reader.Close ();
		}
	}
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:27,代码来源:Program.cs

示例6: RunNotWellFormedTest

	static void RunNotWellFormedTest (string subdir, bool isSunTest)
	{
		string basePath = @"xml-test-suite/xmlconf/" + subdir + @"/not-wf";
		DirectoryInfo [] dirs = null;
		if (isSunTest)
			dirs =  new DirectoryInfo [] {new DirectoryInfo (basePath)};
		else
			dirs = new DirectoryInfo (basePath).GetDirectories ();

		foreach (DirectoryInfo di in dirs) {
			foreach (FileInfo fi in di.GetFiles ("*.xml")) {
				try {
					XmlTextReader xtr = new XmlTextReader (fi.FullName);
					xtr.Namespaces = false;
					while (!xtr.EOF)
						xtr.Read ();
					Console.WriteLine ("Incorrectly wf: " + subdir + "/" + di.Name + "/" + fi.Name);
				} catch (XmlException) {
					// expected
				} catch (Exception ex) {
					Console.WriteLine ("Unexpected Error: " + subdir + "/" + di.Name + "/" + fi.Name + "\n" + ex.Message);
				}
			}
		}
	}
开发者ID:nobled,项目名称:mono,代码行数:25,代码来源:xmltest.cs

示例7: GetItemsList

    public string[] GetItemsList(string prefixText, int count)
    {
        List<string> suggestions = new List<string>();
            using (XmlTextReader reader = new XmlTextReader(HttpContext.Current.Server.MapPath("flightdata.xml")))
            {
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "departurelocation")
                    {
                        string itemName = reader.ReadInnerXml();
                        if (itemName.StartsWith(prefixText, StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (!suggestions.Contains(itemName))
                            suggestions.Add(itemName);

                            if (suggestions.Count == count) break;
                        }
                    }

                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "destinationlocation")
                    {
                        string itemName = reader.ReadInnerXml();
                        if (itemName.StartsWith(prefixText, StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (!suggestions.Contains(itemName))
                            suggestions.Add(itemName);

                            if (suggestions.Count == count) break;
                        }
                    }

                }
            }
            return suggestions.ToArray();
    }
开发者ID:marvinrusinek,项目名称:Skyscanner,代码行数:35,代码来源:Autocomplete.cs

示例8: Main

  static void Main(string[] args)
  {
    string localURL = @"http://ip-address.domaintools.com/myip.xml";
    XmlTextReader xmlreader = null;
    xmlreader = new XmlTextReader (localURL);

    while (xmlreader.Read())
    {
    
    	if(xmlreader.NodeType == XmlNodeType.Element)
    	{
    	
    			Console.WriteLine("Element : " + xmlreader.Name);
    
    	} 

    	if(xmlreader.NodeType == XmlNodeType.Text)
    	{
    		Console.WriteLine("Value : " +xmlreader.Value);
    	}
    }
    if (xmlreader != null)
      xmlreader.Close();

  }
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:25,代码来源:example1.cs

示例9: Mirror

    public Mirror(string spec)
    {
        objectStack = new Stack();
        objectStack.Push(null);

        // Register the commands
        commands = new List<Command>();
        commands.Add(new ElementCommand());
        commands.Add(new EndElementCommand());
        commands.Add(new AttributeCommand());

        Reader = new XmlTextReader(spec);
        while (Reader.Read())
        {
            InterpretCommands();

            var b = Reader.IsEmptyElement;
            if (Reader.HasAttributes)
            {
                for (var i = 0; i < Reader.AttributeCount; i++)
                {
                    Reader.MoveToAttribute(i);
                    InterpretCommands();
                }
            }
            if (b) Pop();
        }
    }
开发者ID:david--liu,项目名称:code_kata,代码行数:28,代码来源:Mirror.cs

示例10: LevelDataXML

 public void LevelDataXML(string pathToXml)
 {
     parseFile = Resources.Load(pathToXml) as TextAsset;
     platforms = new List<PlatformData>();
     metadata = new List<MetaData>();
     portalSpawns = new List<Portal>();
     hazardSpawns = new List<Hazard>();
     playerSpawns = new List<Vector2>();
     enemySpawns = new List<Vector2>();
     items = new List<Vector2>();
     XmlTextReader mapReader = new XmlTextReader(new StringReader(parseFile.text));
     mapReader.Read();
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(mapReader.ReadOuterXml());
     mapSize = new Vector2((float)int.Parse(doc.ChildNodes[0].Attributes[0].Value)/16, (float)int.Parse(doc.ChildNodes[0].Attributes[1].Value)/16);
     for (int x = 0; x < doc.ChildNodes[0].ChildNodes.Count; x++)
     {
         if (doc.ChildNodes[0].ChildNodes[x].Name.ToLower().Equals("frontlayer")) {
             LoadTiles(doc.ChildNodes[0].ChildNodes[x], platforms);
         }
         if (doc.ChildNodes[0].ChildNodes[x].Name.ToLower().Equals("entities"))
         {
             LoadSpawnPoints(doc.ChildNodes[0].ChildNodes[x]);
         }
     }
 }
开发者ID:riktothepast,项目名称:LD30,代码行数:26,代码来源:LevelData.cs

示例11: 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

示例12: 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

示例13: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        XmlReader rd = new XmlTextReader("http://www.tcmb.gov.tr/kurlar/today.xml");
        string kur="",capraz="";
        if (!this.IsPostBack)
        {

            while (rd.Read())
            {
                if (rd.NodeType == XmlNodeType.Element)
                {
                    if (rd.Name == "Isim")
                    {
                        kur = rd.ReadString();
                    }
                    if (rd.Name == "CrossRateUSD")
                    {
                        capraz = rd.ReadString();
                    }
                    if (kur != "" && capraz != "")
                    {
                kurlar.Items.Add(new ListItem(kur, capraz));
                    kur = "";
                    capraz = "";

                    }

                }

            }

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

示例14: GetAlbumArt

    protected void GetAlbumArt(string albumId, string album, string artist)
    {
        string path = Server.MapPath(@"~/images/cover-art/");

        if(!File.Exists(path + albumId + ".png")){
            string url = "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=b25b959554ed76058ac220b7b2e0a026&artist=" + artist + "&album=" + album;
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "GET";
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                XmlTextReader reader = new XmlTextReader(response.GetResponseStream());
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "image")
                    {
                        if (reader.GetAttribute("size").Equals("large"))
                        {
                            url = reader.ReadInnerXml();

                            WebClient webClient = new WebClient();
                            webClient.DownloadFile(url, path + albumId + ".png");
                        }
                    }
                }
            }
            catch (Exception e)
            {
            }
        }
    }
开发者ID:dantomosoiu,项目名称:MusicMachine,代码行数:32,代码来源:UploadSong.aspx.cs

示例15: ReadXML

	private void ReadXML()
	{
		string xmlFile = Server.MapPath("DvdList.xml");

		// Create the reader.
		XmlTextReader reader = new XmlTextReader(xmlFile);

		StringBuilder str = new StringBuilder();
		reader.ReadStartElement("DvdList");

		// Read all the <DVD> elements.
		while (reader.Read())
		{
			if ((reader.Name == "DVD") && (reader.NodeType == XmlNodeType.Element))
			{
				reader.ReadStartElement("DVD");
				str.Append("<ul><b>");
				str.Append(reader.ReadElementString("Title"));
				str.Append("</b><li>");
				str.Append(reader.ReadElementString("Director"));
				str.Append("</li><li>");
				str.Append(String.Format("{0:C}",
					Decimal.Parse(reader.ReadElementString("Price"))));
				str.Append("</li></ul>");
			}
		}
		// Close the reader and show the text.
		reader.Close();
		XmlText.Text = str.ToString();
	}
开发者ID:Helen1987,项目名称:edu,代码行数:30,代码来源:ReadXmlEfficient.aspx.cs


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