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


C# XmlDocument.GetElementsByTagName方法代码示例

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


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

示例1: OnButton4Clicked

 protected void OnButton4Clicked(object sender, System.EventArgs e)
 {
     button4.Visible = false;
     XmlDocument current = new XmlDocument();
     current.Load(Environment.CurrentDirectory + @"\Info.xml");
     XmlNodeList ver1 = current.GetElementsByTagName("Installedversion");
     XmlNodeList update = current.GetElementsByTagName("updatexml");
     XmlNodeList pro = current.GetElementsByTagName("ProgramName");
     string prog = pro[0].InnerText;
     string up1 = update[0].InnerText;
     double cversion = double.Parse(ver1[0].InnerText);
     XmlDocument updater = new XmlDocument();
     updater.Load(up1);
     XmlNodeList ver2 = updater.GetElementsByTagName("LatestVersion");
     double newversion = double.Parse(ver2[0].InnerText);
     if (cversion < newversion)
     {
         label2.Text = "There is a new update for " + prog + ".";
         label3.Text = "Would you like to download it?";
         label4.Text = "Installed Version: " + cversion + " Latest Version: " + newversion;
         button2.Visible = true;
         button3.Label = "No";
     }
     else if (cversion >= newversion)
     {
         label2.Text = "There are no new updates for " + prog + ".";
         button4.Visible = false;
     }
 }
开发者ID:Lomeli12,项目名称:Sharp-Updater,代码行数:29,代码来源:MainWindow.cs

示例2: CharacterSheet_Click

    protected void CharacterSheet_Click(object sender, EventArgs e)
    {
        //If there is no logged in user hide the form and return.
        if (Request["k"] != "L0ngnubby")
        {
            return;
        }

        if (CharacterSheetXML.PostedFile.FileName == null || CharacterSheetXML.PostedFile.FileName == "")
            return; //No file?
        #region File Extension Check
        string[] split = CharacterSheetXML.PostedFile.FileName.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
        switch (split[split.Length - 1].ToLower())
        {
            case "xml":
                break;
            default://I don't know this extension
                return;
        }

        #endregion
        string fileName = Guid.NewGuid().ToString() + "." + split[split.Length - 1].ToLower();
        //Write the file to disk
        StreamReader SR = new StreamReader(CharacterSheetXML.PostedFile.InputStream);
        XmlDocument sheet = new XmlDocument();
        sheet.LoadXml(SR.ReadToEnd());

        BaseStats baseStats = null;
        int MaxHP;

        XmlNodeList xList, xList2;

        xList = sheet.GetElementsByTagName("health");
        if (xList.Count > 0)
        {
            MaxHP = Convert.ToInt32(sheet.GetElementsByTagName("health")[0].Attributes["effective"].Value);
        }
        else MaxHP = 0;
        xList = sheet.GetElementsByTagName("baseStats");
        xList2 = sheet.GetElementsByTagName("secondBar");
        if (xList.Count > 0 && xList2.Count > 0)
        {
            baseStats = new BaseStats(xList[0], MaxHP, xList2[0]);
        }
        Response.Write(baseStats._2ndBar.effective.ToString() + " " + baseStats._2ndBar.Casting + " " + baseStats._2ndBar.NotCasting + " " + baseStats._2ndBar.PerFive);

        RequestData.SqlConnectionString = ""; // Omitted for Git Hub
        PostData.PostCharacterSheetXML(sheet, Request["r"], Request["cn"]);
    }
开发者ID:Velkitor,项目名称:Old-World-Of-Warcraft-Guild-Site,代码行数:49,代码来源:UploadCharacterSheet.aspx.cs

示例3: XMLParser

    public XMLParser(String filePath)
    {
        dt = new DataTable();
        dt.TableName = "tyontekijat";

        dt.Columns.Add("etunimi", typeof(String));
        dt.Columns.Add("sukunimi", typeof(String));
        dt.Columns.Add("numero", typeof(String));
        dt.Columns.Add("tyosuhde", typeof(String));
        dt.Columns.Add("palkka", typeof(int));
        dt.Columns.Add("vakituiset", typeof(int));
        dt.Columns.Add("palkat yht", typeof(int));

        for (int i = 0; i < dt.Columns.Count; i++)
        {
            dt.Columns[i].ReadOnly = false;
        }

        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load(filePath);

        etunimiLista = xmlDoc.GetElementsByTagName("etunimi");
        sukunimiLista = xmlDoc.GetElementsByTagName("sukunimi");
        numeroLista = xmlDoc.GetElementsByTagName("numero");
        tyosuhdeLista = xmlDoc.GetElementsByTagName("tyosuhde");
        palkkaLista = xmlDoc.GetElementsByTagName("palkka");
    }
开发者ID:Raedot,项目名称:IIO13200-OHJELMOINTIKOE,代码行数:27,代码来源:XMLParser.cs

示例4: Read

 public Quest Read(XmlDocument document, uint ID)
 {
     string title = document.GetElementsByTagName("ID" + ID.ToString()).Item(0).ChildNodes.Item(0).InnerText;
     string desc = document.GetElementsByTagName("ID" + ID.ToString()).Item(0).ChildNodes.Item(1).InnerText;
     uint next = uint.Parse(document.GetElementsByTagName("ID" + ID.ToString()).Item(0).ChildNodes.Item(2).InnerText);
     return new Quest(ID, title, desc, next);
 }
开发者ID:znickz59,项目名称:RPG,代码行数:7,代码来源:XmlReader.cs

示例5: Start

//List<Dictionary<string,string>> pictures = new List<Dictionary<string,string>>();
//Dictionary<string,string> obj;

IEnumerator Start()
{
	//Load XML data from a URL
	//string url = "http://vvtest.ucoz.com/picturesReal.xml";
	string url = "http://85.255.65.168/XML/pictureInformation.xml"; //For now all comes from Ucoz FTP, because real server is not running. Bellow link for server

	WWW www = new WWW(url);

	//Load the data and yield (wait) till it's ready before we continue executing the rest of this method.
	yield return www;
	if (www.error == null)
	{
		//Sucessfully loaded the XML
		Debug.Log("Loaded following XML " + www.data);

		//Create a new XML document out of the loaded data
		XmlDocument xmlDoc = new XmlDocument();
		xmlDoc.LoadXml(www.data);
		XmlNodeList levelsList = xmlDoc.GetElementsByTagName("picture"); // array of the level nodes.
		XmlNodeList linkList = xmlDoc.GetElementsByTagName("links"); // array of the level nodes.

		int mPictureIdentificator = theRealPicture - 1;

	}
	else
	{//Error

		Debug.Log("ERROR: " + www.error);
	}
}
开发者ID:BuLLeTCode,项目名称:Riga_Cathedral_Project,代码行数:33,代码来源:ProcessingBehaviour.cs

示例6: Main

    public static int Main(string[] args)
    {
        // parse the command line
        CommandLineArguments cmdLine = CommandLineParser.Parse(new string[] {}, args);
        if(cmdLine.GetArguments().Length != 1)
        {
            Usage();
            return FAIL_CODE;
        }

        string testFile = cmdLine.GetArguments()[0];

        // parse the test file
        TestGroup[] groups = null;
        try
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(testFile);

            // Load up the algorithm tables
            Hashtable algorithms = ParseAlgorithms((XmlElement)doc.GetElementsByTagName("HashFunctions")[0]);

            // Load the test cases
            groups = ParseTestCases((XmlElement)doc.GetElementsByTagName("Tests")[0], algorithms);
        }
        catch(Exception e)
        {
            Console.Error.WriteLine("Error parsing input file : " + e.Message);
            return FAIL_CODE;
        }

        // setup the tests
        TestRunner runner = new TestRunner(groups, new ILogger[] { new ConsoleLogger(), new XmlLogger()});
        return runner.Run("HashDriver") ? PASS_CODE : FAIL_CODE;
    }
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:35,代码来源:HashDriver.cs

示例7: btnIngresar_Click

    protected void btnIngresar_Click(object sender, EventArgs e)
    {
        XmlDocument doc = new XmlDocument();
        string xurl = ConfigurationManager.ConnectionStrings["URL"].ConnectionString;
        string metodo = "Login/";
        if ((this.Nickname.Text != "" & this.Password.Text != "") && (this.Nickname.Text != "Nombre Usuario" & this.Password.Text != "Contraseña"))
        {
            string rut = removeRut(this.Nickname.Text);
            string pass = this.Password.Text;
            string passEncode = textToBase64(pass);
            string URL = xurl + metodo + rut + "," + passEncode;
            doc.Load(URL);

            XmlNodeList estado = doc.GetElementsByTagName("status");
            XmlNodeList name = doc.GetElementsByTagName("name");
            XmlNodeList user = doc.GetElementsByTagName("user");

            if (estado[0].ChildNodes[0].InnerText == "Success")
            {
                Session["login"] = true;
                Session["User"] = user[0].ChildNodes[0].InnerText;
                Session["name"] = name[0].ChildNodes[0].InnerText;
                Response.Redirect("mensajes_enviados.aspx");
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('Usuario no valido.');", true);
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('Ingrese datos validos.');", true);
        }
    }
开发者ID:RCortes,项目名称:BBVA,代码行数:34,代码来源:index.aspx.cs

示例8: RequestGeocodeAddress

    public GeocodeAddress RequestGeocodeAddress(String address)
    {
        //�����������geocoder��
        String urlString = "http://geocoder.us/service/rest/geocode?address=" + HttpUtility.UrlEncode(address);
        HttpWebRequest getRequest = (HttpWebRequest)WebRequest.Create(urlString);
        getRequest.Method = "GET";
        WebResponse response = null;

        response = getRequest.GetResponse();
        Stream responseStream = response.GetResponseStream();

        GeocodeAddress addr = new GeocodeAddress();

        XmlDocument doc = new XmlDocument();
        doc.Load(responseStream);

        addr.lon = doc.GetElementsByTagName("geo:long").Item(0).FirstChild.Value;
        addr.lat = doc.GetElementsByTagName("geo:lat").Item(0).FirstChild.Value;

        address = doc.GetElementsByTagName("dc:description").Item(0).FirstChild.Value;
        int sep = address.IndexOf(',');
        if (sep != -1)
        {
            addr.address1 = address.Substring(0, sep);
            addr.address2 = address.Substring(sep + 1);
        }
        else
        {
            addr.address1 = address;
        }

        return addr;
    }
开发者ID:guchanghai,项目名称:Cut,代码行数:33,代码来源:Geocoding.cs

示例9: read

    static string read(string xmlString)
    {
        string temp = string.Empty;
        string condi = string.Empty;
        string weather = string.Empty;
        XmlDocument doc = new XmlDocument();
        doc.LoadXml(xmlString);

        XmlNodeList location = doc.GetElementsByTagName("yweather:location");
        foreach (XmlNode xNode in location)
        {
            XmlElement town = (XmlElement)xNode;
            weather = town.Attributes.GetNamedItem("city").InnerText + " " +
                    town.Attributes.GetNamedItem("country").InnerText + " Weather";
        }
        XmlNodeList condition = doc.GetElementsByTagName("yweather:condition");
        foreach (XmlNode xNode in condition)
        {
            XmlElement status = (XmlElement)xNode;
            condi = status.Attributes.GetNamedItem("text").InnerText;
            temp = status.Attributes.GetNamedItem("temp").InnerText;
        }

        string msg = weather + Environment.NewLine + condi + Environment.NewLine +
            " " + temp + "F | " + celcus(temp.Trim()).Substring(4) + "C";
        return msg;
    }
开发者ID:kingpauloaquino,项目名称:smsCore-Management,代码行数:27,代码来源:forecastController.cs

示例10: compressImage

    public static void compressImage(Media sender)
    {
        //Get settings file
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load(HttpContext.Current.Server.MapPath("~/config/WaffelAutoCompress.config"));
        var propertyAlias = xmlDoc.GetElementsByTagName("propertyalias")[0].InnerText;
        var mediaTypes = xmlDoc.GetElementsByTagName("mediatypes")[0].InnerText;
        bool allowedMediaType = mediaTypes.Split(',').Contains(sender.ContentType.Alias.ToString());

        //Check if settings allow current mediatype and if upload property has value
        if (allowedMediaType && sender.getProperty(propertyAlias).Value.ToString().Length != 0)
        {
            var triggerSize = xmlDoc.GetElementsByTagName("triggersize")[0].InnerText;
            var fileTypes = xmlDoc.GetElementsByTagName("filetypes")[0].InnerText;

            //Get uploaded file
            string targetFilePath = HttpContext.Current.Server.MapPath(sender.getProperty(propertyAlias).Value.ToString());
            var file = File.Open(targetFilePath, FileMode.Open, FileAccess.ReadWrite);
            string fileName = file.Name.ToString();
            var ext = fileName.Substring(fileName.LastIndexOf(".") + 1, fileName.Length - fileName.LastIndexOf(".") - 1).ToLower();

            int maxFileSize = System.Convert.ToInt32(triggerSize) * 1024; // if above image is downscaled
            bool allowedExt = fileTypes.Split(',').Contains(ext);

            //Check if file type is allowed and if size is above triggersize
            if (maxFileSize <= file.Length && allowedExt)
            {
                ImageDownscale(file, sender, ext);
            }
            else file.Dispose();
        }
    }
开发者ID:eoutvik,项目名称:Waffel_AutoCompress,代码行数:32,代码来源:WaffelImageCompressor.cs

示例11: GetGeographicalCoordinatesCoroutine

 private IEnumerator GetGeographicalCoordinatesCoroutine()
 {
     Input.location.Start();
     int maximumWait = 20;
     while(Input.location.status == LocationServiceStatus.Initializing  && maximumWait > 0)
     {
         yield return new WaitForSeconds(1);
         maximumWait--;
     }
     //if(maximumWait < 1 || Input.location.status == LocationServiceStatus.Failed)
     if(maximumWait < 1 && Input.location.status == LocationServiceStatus.Failed)
     {
         Input.location.Stop();
         yield break;
     }
     float latitude = Input.location.lastData.latitude;
     float longitude = Input.location.lastData.longitude;
     //      Asakusa.
     //      float latitude = 35.71477f;
     //      float longitude = 139.79256f;
     Input.location.Stop();
     //LOcation Barcelona
     //https://maps.googleapis.com/maps/api/geocode/xml?latlng=41.3850640,2.1734030
     WWW www = new WWW("https://maps.googleapis.com/maps/api/geocode/xml?latlng=" + latitude + "," + longitude + "&sensor=true");
     yield return www;
     if(www.error != null) yield break;
     XmlDocument reverseGeocodeResult = new XmlDocument();
     reverseGeocodeResult.LoadXml(www.text);
     if(reverseGeocodeResult.GetElementsByTagName("status").Item(0).ChildNodes.Item(0).Value != "OK") yield break;
     string countryCode = string.Empty;
     string countryName = string.Empty;
     bool countryFound = false;
     foreach(XmlNode eachAdressComponent in reverseGeocodeResult.GetElementsByTagName("result").Item(0).ChildNodes)
     {
         if(eachAdressComponent.Name == "address_component")
         {
             foreach(XmlNode eachAddressAttribute in eachAdressComponent.ChildNodes)
             {
                 if(eachAddressAttribute.Name == "short_name"){
                     countryCode = eachAddressAttribute.FirstChild.Value;
                 }
                 if(eachAddressAttribute.Name == "long_name"){
                     countryName = eachAddressAttribute.FirstChild.Value;
                 }
                 if(eachAddressAttribute.Name == "type" ||  eachAddressAttribute.FirstChild.Value == "country"){
                     countryFound = true;
                 }
             }
             if(countryFound) break;
         }
     }
     if(countryFound && countryCode != null)
         //PlayerPrefs.SetString(playerPrefsKey,countryCode);
         Debug.Log(countryCode);
         Debug.Log(countryName);
 }
开发者ID:jmoraltu,项目名称:KatoizApp,代码行数:56,代码来源:Geolocation.cs

示例12: ParseContent

 private void ParseContent(string content)
 {
     XmlDocument document = new XmlDocument();
     document.LoadXml(content);
     XmlNodeList list = document.GetElementsByTagName("Part");
     XmlElement element = (XmlElement)list.Item(0);
     this._ID = System.Convert.ToInt32(element.GetAttribute("id"));
     this._total = System.Convert.ToInt32(element.GetAttribute("total"));
     list = document.GetElementsByTagName("Value");
     element = (XmlElement)list.Item(0);
     this._data = element.InnerXml;
 }
开发者ID:spox,项目名称:irisim,代码行数:12,代码来源:Part.cs

示例13: cmdUpdate_Click

    protected void cmdUpdate_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(pklTitle.PickListValue))
        {
            throw new Sage.Platform.Application.ValidationException("Status must be contain data");
        }
        else
        {
            GroupInfo groupInfo = GroupInfo.GetGroupInfo(lkpGroupName.SelectedValue);
            string WhereSQL = groupInfo.WhereSQL.Trim();
            string fromSQL = groupInfo.FromSQL.Trim();
            NHibernate.ISession session = new Sage.Platform.Orm.SessionScopeWrapper();
            string sql = string.Empty;
            if (string.IsNullOrEmpty(WhereSQL))
            {
                sql = "select distinct salesorderid from " + fromSQL;
            }
            else
            {
                sql = "select distinct salesorderid from " + fromSQL + " where " + WhereSQL + "";
            }
            System.Collections.IList test = session.CreateSQLQuery(sql).List();
            string ids = string.Empty;
            for (int i = 0; i < test.Count; ++i)
            {
                ids = "update salesorder set status='" + pklTitle.PickListValue.ToString().Trim() + "' where salesorderid='"+test[i].ToString() + "'";
                session.CreateSQLQuery(ids).ExecuteUpdate();
            }
            string alias = string.Empty;
            XmlDocument xmldoc = new XmlDocument();
            xmldoc.LoadXml(groupInfo.GroupXML);
            string selectSQL = ((XmlElement)xmldoc.GetElementsByTagName("selectsql")[0]).InnerText;
            XmlNodeList layoutNodes = xmldoc.GetElementsByTagName("layout");

            foreach (XmlElement node in layoutNodes)
            {
                XmlNodeList nAlias = node.GetElementsByTagName("caption");
                alias = nAlias[0].InnerText;
            }

            if (string.IsNullOrEmpty(WhereSQL))
            {
                sql = "Select " + selectSQL + " from " + fromSQL;
            }
            else
            {
                sql = "Select " + selectSQL + " from " + fromSQL + " where " + WhereSQL + "";
            }
            dsGroup.SelectCommand = sql;

        }
    }
开发者ID:pebre77,项目名称:PrxS2,代码行数:52,代码来源:UpdateSalesOrderStatus.ascx.cs

示例14: Blog

 public Blog(string rssUri)
 {
     this.rssUri = rssUri;
     var xmlDocument = new XmlDocument();
     xmlDocument.Load(rssUri);
     uri = xmlDocument.GetElementsByTagName("link")[0].InnerText;
     title = xmlDocument.GetElementsByTagName("title")[0].InnerText;
     articles = new List<Article>();
     foreach (var article in GetArticlesFromXmlDocument(xmlDocument))
     {
         articles.Add(article);
     }
 }
开发者ID:sinshu,项目名称:rss_uneune,代码行数:13,代码来源:Blog.cs

示例15: initialiseSpellButtons

 public void initialiseSpellButtons(XmlDocument xmlDoc)
 {
     XmlNodeList spellList = xmlDoc.GetElementsByTagName("spells")[0].ChildNodes;
     for(int i = 0; i < spellButtons.Length; i++) {
         CmdSpawn(i, spellList[i].LastChild.InnerText);
     }
 }
开发者ID:CalvoR,项目名称:2016_3A_Unity_Calvo_GodVSMan,代码行数:7,代码来源:gvmGodSceneManager.cs


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