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


C# XmlTextReader.ReadToFollowing方法代码示例

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


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

示例1: GetText

    public static string GetText(string key)
    {
        XmlTextReader reader = new XmlTextReader(new StringReader(copySource.text));

        string outString = "";

        // replace "EN" with language code, once implemented

        while(reader.Read()){
            if (reader.IsStartElement(key)){
                reader.ReadToFollowing("EN");
                outString = reader.ReadElementContentAsString("EN", reader.NamespaceURI);
            }
        }

        return outString;
    }
开发者ID:chorgan93,项目名称:selfportraitoftheartist,代码行数:17,代码来源:TextSource.cs

示例2: WindButton_Click

    protected void WindButton_Click(object sender, EventArgs e)
    {
        // find wind speed
        try
        {
            WindService.Service1Client myClient = new WindService.Service1Client();
            decimal windSp = myClient.WindIntensity(Convert.ToDecimal(latTextBox.Text), Convert.ToDecimal(longTextBox.Text)); // calls service
            if (knotsRadio.Checked == true)
                speedLabel.Text = windSp.ToString("N3") + " knots";  // outputs results in knots
            else
                speedLabel.Text = JbClass.convertToMph(Convert.ToDouble(windSp)).ToString("N3") + " mph";  // converts from knots to mph

            myClient.Close();
        }
        catch (InvalidCastException) { }
        catch (FormatException) // if both fields aren't selected
        {
            speedLabel.Text = "Please enter both fields";
        }
        catch (Exception) { }

        // find elevation
        try
        {
            decimal lat = Convert.ToDecimal(latTextBox.Text);
            decimal longi = Convert.ToDecimal(longTextBox.Text);

            int inum = Session.Count + 1;
            if (inum >= 6)
            {
                string place2 = (string)Session["place2"];
                string place3 = (string)Session["place3"];
                string place4 = (string)Session["place4"];
                string place5 = (string)Session["place5"];
                Session["place1"] = place2;
                Session["place2"] = place3;
                Session["place3"] = place4;
                Session["place4"] = place5;
                Session["place5"] = latTextBox.Text + ", " + longTextBox.Text;
            }
            else
            {
                string num = Convert.ToString(inum);
                string catalogKey = "place" + num;
                Session[catalogKey] = latTextBox.Text + ", " + longTextBox.Text;
            }

            string url = string.Format("http://webstrar31.fulton.asu.edu/page0/page00/service1.svc/elev?latitude={0}&longitude={1}", lat, longi);

            // create http request from string URL
            HttpWebRequest elevRequest = (HttpWebRequest)WebRequest.Create(url);

            // send webrequest and wait for response
            HttpWebResponse elevResponse = (HttpWebResponse)elevRequest.GetResponse();

            // get stream associated with response
            Stream elevReceiver = elevResponse.GetResponseStream();

            // copy the data from XML format into a string
            XmlTextReader reader = new XmlTextReader(elevReceiver);
            reader.ReadToFollowing("decimal");
            decimal elevation = reader.ReadElementContentAsDecimal();

            if (feetRadio.Checked == true)
                elevationLabel.Text = elevation.ToString("N2") + " feet above sea level";
            else
                elevationLabel.Text = JbClass.convertToMeters(Convert.ToDouble(elevation)).ToString("N2") + " meters above sea level";
        }
        catch (FormatException) { elevationLabel.Text = "Please enter both fields"; }
        catch (Exception) { }
    }
开发者ID:jjipson,项目名称:assignment5,代码行数:71,代码来源:Page2.aspx.cs

示例3: readConfig

        void readConfig(string path)
        {
            int i = 0;
            int j = 0;
            int k = 0;
            uint lastZoneTemp = 10;
            uint firstZoneTemp;
            XmlTextReader reader = new XmlTextReader(path);
            {
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        switch (reader.NodeType)
                        {
                            case XmlNodeType.Element:
                                reader.ReadToFollowing("expander");//Configure Expanders
                                do
                                {
                                    swampExpanderTypes[i] = reader.GetAttribute("Type");
                                    expanderIDs[i] = Convert.ToUInt16(reader.GetAttribute("ID"));

                                    if (swampExpanderTypes[i] == "swampE4")
                                    {
                                        lastZoneTemp += 4;
                                        firstZoneTemp = lastZoneTemp - 3;
                                    }
                                    else
                                    {
                                        lastZoneTemp += 8;
                                        firstZoneTemp = lastZoneTemp - 7;
                                    }
                                    expanderLastZone[i] = lastZoneTemp;
                                    expanderFirstZone[i] = firstZoneTemp;
                                    i++;
                                } while (reader.ReadToNextSibling("expander"));
                                numberOfExpanders = (ushort)i;
                                i = 0;

                                reader.ReadToFollowing("audioZone"); //Audio Zone Names & Numbers
                                do
                                {
                                    zoneNameArray[i] = reader.GetAttribute("Name");
                                    zoneNumberArray[i] = Convert.ToUInt16(reader.GetAttribute("zoneNumber"));
                                    i++;
                                    if (zoneNameArray[i] != " ")
                                    {
                                        k++;
                                    }
                                } while (reader.ReadToNextSibling("audioZone"));
                                numberOfZones = (ushort)k;

                                i = 1;
                                reader.ReadToFollowing("audioSource"); //Audio Source Names & Numbers
                                sourceNameArray[0] = "Off";
                                do
                                {
                                    sourceNameArray[i] = reader.GetAttribute("Name");
                                    i++;
                                } while (reader.ReadToNextSibling("audioSource"));

                                i = 0;
                                reader.ReadToFollowing("group");//group numbers
                                do
                                {
                                    groupNames[i] = reader.GetAttribute("Name");
                                    reader.ReadToFollowing("zone");
                                    do
                                    {
                                        UItoZone.zoneNumbersInGroups[i, j] = Convert.ToUInt16(reader.GetAttribute("zoneNumber"));//add zone numbers per floor/group
                                        j++;
                                    } while (reader.ReadToNextSibling("zone"));
                                    UItoZone.groupSizes[i] = (ushort)j;//Number of zones in groups
                                    j = 0;
                                    i++;
                                } while (reader.ReadToNextSibling("group"));
                                UItoZone.numberOfGroups = i;
                                break;
                        } break;

                    }

                }
            }
        }
开发者ID:rvanderluit,项目名称:AV,代码行数:85,代码来源:ControlSystem.cs

示例4: LoadTMX

    public void LoadTMX(string fileName)
    {
        // load xml document
        TextAsset dataAsset = (TextAsset) Resources.Load (fileName, typeof(TextAsset));
        if(!dataAsset) {
            Debug.Log ("FTiledScene: Couldn't load the xml data from: " + fileName);
        }
        Resources.UnloadAsset(dataAsset);

        // parse xml string
        XmlTextReader mapReader = new XmlTextReader(new StringReader(dataAsset.text));
        mapReader.Read();

        // build tilesets
        while (mapReader.ReadToFollowing("tileset")) {
           	CreateElementsForTileMap(mapReader);
        }

        // reset xmlreader
        mapReader = new XmlTextReader(new StringReader(dataAsset.text));

        // build layer grids
        string layer = "";
        for (int u = 0; u < 10; u++) {
            mapReader.ReadToFollowing("layer");
            layer = mapReader[0];

            if (layer == "9")
                Grid_9 = loadSpriteLayer(mapReader, 9);
            else if (layer == "8")
                Grid_8 = loadSpriteLayer(mapReader, 8);
            else if (layer == "7")
                Grid_7 = loadSpriteLayer(mapReader, 7);
            else if (layer == "6")
                Grid_6 = loadSpriteLayer(mapReader, 6);
            else if (layer == "5")
                Grid_5 = loadSpriteLayer(mapReader, 5);
            else if (layer == "4")
                Grid_4 = loadSpriteLayer(mapReader, 4);
            else if (layer == "3")
                Grid_3 = loadSpriteLayer(mapReader, 3);
            else if (layer == "2")
                Grid_2 = loadSpriteLayer(mapReader, 2);
            else if (layer == "1")
                Grid_1 = loadSpriteLayer(mapReader, 1);
            else if (layer == "Collision")
                Grid_Collision = loadCollisionLayer(mapReader);
        }

        BuildTiles();
    }
开发者ID:jfleschler,项目名称:Futile_TMX_Demo,代码行数:51,代码来源:Level.cs


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