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


C# XmlDataDocument.Load方法代碼示例

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


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

示例1: getWeatherData

        public IDictionary<String, String> getWeatherData(String lat, String lon)
        {
            XmlDataDocument doc = new XmlDataDocument();
            IDictionary<String, String> data = new Dictionary<String, String>();
            String url ="http://api.openweathermap.org/data/2.5/forecast/daily?lat=" + lat + "&lon=" + lon + "&cnt=5&mode=xml";
            doc.Load(url);

            XmlNodeList locationList = doc.GetElementsByTagName("location");
            XmlNodeList foreCastList = doc.GetElementsByTagName("time");

            data["City"] = locationList[0].SelectSingleNode("name").InnerText;
            data["Country"] = locationList[0].SelectSingleNode("country").InnerText;

            String temperature,wind,clouds;

            for (int i = 0; i < 5; i++)
            {
                temperature = "Temperature : Morn = " + foreCastList[i].SelectSingleNode("temperature").Attributes["morn"].Value +
                            ",Evening = " + foreCastList[i].SelectSingleNode("temperature").Attributes["eve"].Value + ",Night = " + foreCastList[i].SelectSingleNode("temperature").Attributes["night"].Value;
                wind = "Wind : " + foreCastList[i].SelectSingleNode("windSpeed").Attributes["name"].Value;
                clouds = "Clouds : " + foreCastList[i].SelectSingleNode("clouds").Attributes["value"].Value;

                data[foreCastList[i].Attributes["day"].Value] = temperature + " | " + wind + " | " + clouds;
            }
            return data;
        }
開發者ID:sravyaguturu,項目名稱:c-WebServices,代碼行數:26,代碼來源:Weather.svc.cs

示例2: getLatLong

        public IDictionary<String, String> getLatLong(String zipCode)
        {
            XmlDataDocument doc = new XmlDataDocument();
            List<String> data = new List<String>();
            String url = "http://maps.googleapis.com/maps/api/geocode/xml?address=" + zipCode;
            doc.Load(url);

            XmlNodeList status = doc.GetElementsByTagName("status");
            String res_status = status[0].InnerText;
            if (!res_status.Equals("OK"))
            {
                data.Add("No Result");
            }

            XmlNodeList result = doc.GetElementsByTagName("result");
            XmlNodeList list = null,location = null;

            String latitude = null, longitude = null;

            for (int i = 0; i < result.Count; i++)
            {
                list = doc.GetElementsByTagName("geometry");
            }
            for (int i = 0; i < list.Count; i++)
            {
                location = doc.GetElementsByTagName("location");
            }

            latitude = location[0].SelectSingleNode("lat").InnerText;
            longitude = location[0].SelectSingleNode("lng").InnerText;
            return  getWeatherData(latitude,longitude);
        }
開發者ID:sravyaguturu,項目名稱:c-WebServices,代碼行數:32,代碼來源:Weather.svc.cs

示例3: createCsvFile

        private void createCsvFile()
        {
            XmlDataDocument xmldoc = new XmlDataDocument();
            string name = null;
            string year = null;
            string corp = null;
            string line = null;
            string code = null;
            XmlNodeList childs = null;
            StreamWriter file = new StreamWriter(mamePath + "roms.csv", false);
            FileStream fs = new FileStream(mamePath + "mame.xml", FileMode.Open, FileAccess.Read);
            xmldoc.Load(fs);
            XmlNodeList machineNodes = xmldoc.GetElementsByTagName("machine");

            for (int i = 0; i < machineNodes.Count; i++)
            {
                code = machineNodes[i].Attributes.GetNamedItem("name").InnerText.Trim();
                childs = machineNodes[i].ChildNodes;
                name = childs.Count > 0 ?  childs.Item(0).InnerText.Trim() : "";
                year = childs.Count > 1 ? childs.Item(1).InnerText.Trim() : "";
                corp = childs.Count > 2 ? childs.Item(2).InnerText.Trim() : "";
                line = segment(code) + ", " + segment(name)  + ", " + segment(year) + ", " + segment(corp);
                file.WriteLine(line);
                //if (i > 10) {
                //    break;
                //}
            }
            file.Close();
            fs.Close();
        }
開發者ID:MyroStadler,項目名稱:MAME-Tool,代碼行數:30,代碼來源:MainWindow.xaml.cs

示例4: button1_Click

        private void button1_Click(object sender, System.EventArgs e)
        {
            XmlDataDocument doc = new XmlDataDocument ();
            doc.Load ( "locdata.xml" );
            XmlNodeList nodes = doc.GetElementsByTagName("city");
            foreach ( XmlNode n in nodes )
            {
                listBox1.Items.Add ( n.InnerText );

            }
            label1.Text = string.Format("Total {0} Item(s).", listBox1.Items.Count);

            //			StreamReader reader = new StreamReader ( "loctest2.csv" );
            //			string contents = reader.ReadToEnd ();
            //			reader.Close ();
            //			foreach ( string s in contents.Split ( "\n\r".ToCharArray() ) )
            //			{
            //				if ( s.Trim() == string.Empty ) continue;
            //				foreach ( string p in s.Split ( ",".ToCharArray() ) )
            //				{
            //					string temp = p.Replace ( "\"", "" );
            //					listBox1.Items.Add ( temp.Trim() );
            //				}
            //
            //
            //			}
        }
開發者ID:usmanghani,項目名稱:Misc,代碼行數:27,代碼來源:Form1.cs

示例5: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            //try
            //{
                if (this.RssUrl.Length == 0)
                    throw new ApplicationException("Не указана ссылка на RSS-ленту.");

                XmlDataDocument feed = new XmlDataDocument();
                feed.Load(GetFullUrl(this.RssUrl));
                XmlNodeList posts = feed.GetElementsByTagName("item");

                DataTable table = new DataTable("Feed");
                table.Columns.Add("Title", typeof(string));
                table.Columns.Add("Description", typeof(string));
                table.Columns.Add("Link", typeof(string));
                table.Columns.Add("PubDate", typeof(DateTime));

                foreach (XmlNode post in posts)
                {
                    DataRow row = table.NewRow();
                    row["Title"] = post["title"].InnerText;
                    row["Description"] = post["description"].InnerText.Trim();
                    row["Link"] = post["link"].InnerText;
                    row["PubDate"] = DateTime.Parse(post["pubDate"].InnerText);
                    table.Rows.Add(row);
                }

                dlArticles.DataSource = table;
                dlArticles.DataBind();
            //}
            /*catch (Exception)
            {
                this.Visible = false;
            }*/
        }
開發者ID:Nevs12,項目名稱:LiveandevSite,代碼行數:35,代碼來源:RssReader.ascx.cs

示例6: readChannelFeed

    public void readChannelFeed()
    {
        XmlDataDocument xmldoc = new XmlDataDocument();
        XmlNodeList xmlnode;
        int i = 0;
        //string str = null;
        xmldoc.Load(formHTTPrequest());
        xmlnode = xmldoc.GetElementsByTagName("feed");
        feedCount = xmlnode.Count;

        dates = new string[xmlnode.Count];
        ids = new string[xmlnode.Count];
        temp = new string[xmlnode.Count];
        air = new string[xmlnode.Count];
        soil = new string[xmlnode.Count];
        light = new string[xmlnode.Count];
        co2_1 = new string[xmlnode.Count];
        co2_2 = new string[xmlnode.Count];
        out_temp = new string[xmlnode.Count];

        for (i = 0; i <= xmlnode.Count - 1; i++)
        {
            dates[i] = xmlnode[i].ChildNodes.Item(0).InnerText.Trim();
            ids[i] = xmlnode[i].ChildNodes.Item(1).InnerText.Trim();
            temp[i] = xmlnode[i].ChildNodes.Item(2).InnerText.Trim();
            air[i] = xmlnode[i].ChildNodes.Item(3).InnerText.Trim();
            soil[i] = xmlnode[i].ChildNodes.Item(4).InnerText.Trim();
            light[i] = xmlnode[i].ChildNodes.Item(5).InnerText.Trim();
            co2_1[i] = xmlnode[i].ChildNodes.Item(6).InnerText.Trim();
            co2_2[i] = xmlnode[i].ChildNodes.Item(7).InnerText.Trim();
            out_temp[i] = xmlnode[i].ChildNodes.Item(8).InnerText.Trim();

        }
    }
開發者ID:kristijonaslucenko,項目名稱:Smart_Plant,代碼行數:34,代碼來源:ThingsSpeakFeedReader.cs

示例7: Form1_Load

 private void Form1_Load(object sender, System.EventArgs e)
 {
     this.dataSet1.ReadXmlSchema ( "locdataschema.xsd" );
     XmlDataDocument datadoc = new XmlDataDocument ( dataSet1 );
     datadoc.Load ( "locdata.xml" );
     this.dataGrid1.DataSource = this.dataSet1.Tables["loctest"];
 }
開發者ID:usmanghani,項目名稱:Misc,代碼行數:7,代碼來源:Form1.cs

示例8: AddLink

        public void AddLink(string title, string uri)
        {
            XmlDocument doc = new XmlDataDocument();
            doc.Load("RssLinks.xml");
            XmlNode rootNode = doc.SelectSingleNode("links");

            XmlNode linkNode = doc.CreateElement("link");

            XmlNode titleNode = doc.CreateElement("title");
            XmlText titleText = doc.CreateTextNode(title);
            titleNode.AppendChild(titleText);

            XmlNode uriNode = doc.CreateElement("uri");
            XmlText uriText = doc.CreateTextNode(uri);
            uriNode.AppendChild(uriText);

            XmlNode defaultshowNode = doc.CreateElement("defaultshow");
            XmlText defaultshowText = doc.CreateTextNode("false");
            defaultshowNode.AppendChild(defaultshowText);

            linkNode.AppendChild(titleNode);
            linkNode.AppendChild(uriNode);
            linkNode.AppendChild(defaultshowNode);

            rootNode.AppendChild(linkNode);

            doc.Save("RssLinks.xml");
        }
開發者ID:jun-quan-Lai,項目名稱:RSSReader,代碼行數:28,代碼來源:RssLinkXML.cs

示例9: loaddata

    public void loaddata()
    {
        XmlDataDocument xml = new XmlDataDocument();
        xml.Load(Server.MapPath("~/" + "ad.xml"));

        XmlNodeList nodes = xml.SelectSingleNode("ttt").ChildNodes;

        DataTable dt = new DataTable();

        dt.Columns.Add("index", typeof(string));
        dt.Columns.Add("src", typeof(string));
        dt.Columns.Add("href", typeof(string));
        dt.Columns.Add("target", typeof(string));

        foreach (XmlNode node in nodes)
        {
            DataRow row = dt.NewRow();

            row["href"] = node.Attributes["href"].Value;
            row["src"] = node.Attributes["src"].Value;
            dt.Rows.Add(row);
        }

        DataList4.DataSource = dt;
        DataList4.DataBind();
    }
開發者ID:kavilee2012,項目名稱:kvShop,代碼行數:26,代碼來源:index.aspx.cs

示例10: ConfigXML

        XmlNode root = null;//根節點
        public ConfigXML()
        {

            XmlDataDocument configXMLDocu = new XmlDataDocument();
            configXMLDocu.Load("./config.xml");
            root = configXMLDocu.DocumentElement;
            
        }
開發者ID:liguifa,項目名稱:carpNote,代碼行數:9,代碼來源:ConfigXML.cs

示例11: Main

 static void Main()
 {
     XmlDocument doc = new XmlDataDocument();
     doc.Load(@"..\..\..\Catalogue.xml");
     var albumNodes = doc.DocumentElement.ChildNodes;
     foreach (XmlNode albumNode in albumNodes)
     {
         Console.WriteLine(albumNode["catalogue:name"].InnerText);
     }
 }
開發者ID:PlamenaMiteva,項目名稱:Database_Applications,代碼行數:10,代碼來源:02.+Extract+Album+Names.cs

示例12: LoadXmlDataDocument

		void LoadXmlDataDocument (XmlDataDocument document)
		{
			if (Transform == "" && TransformFile == "") {
				if (DataFile != "")
					document.Load (MapPathSecure (DataFile));
				else
					document.LoadXml (Data);
			} else {
				throw new NotImplementedException ("XSLT transform not implemented");
			}
		}
開發者ID:jjenki11,項目名稱:blaze-chem-rendering,代碼行數:11,代碼來源:XmlDataSource.cs

示例13: button1_Click

 private void button1_Click(object sender, EventArgs e)
 {
     XmlDataDocument xmldoc = new XmlDataDocument();
     XmlNode xmlnode ;
     FileStream fs = new FileStream("tree.xml", FileMode.Open, FileAccess.Read);
     xmldoc.Load(fs);
     xmlnode = xmldoc.ChildNodes[1];
     treeView1.Nodes.Clear();
     treeView1.Nodes.Add(new TreeNode(xmldoc.DocumentElement.Name));
     TreeNode tNode ;
     tNode = treeView1.Nodes[0];
     AddNode(xmlnode, tNode);
 }
開發者ID:braithair,項目名稱:work,代碼行數:13,代碼來源:xml.cs

示例14: openToolStripMenuItem_Click

 private void openToolStripMenuItem_Click(object sender, EventArgs e)
 {
     OpenFileDialog dialog = new OpenFileDialog();
     dialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
     if (dialog.ShowDialog() == DialogResult.OK)
     {
         XmlDataDocument xmldoc = new XmlDataDocument();
         XmlReaderSettings settings = new XmlReaderSettings();
         settings.IgnoreWhitespace = true;
         settings.ProhibitDtd = false;
         XmlUrlResolver resolver = new XmlUrlResolver();
         resolver.Credentials = CredentialCache.DefaultCredentials;
         settings.XmlResolver = resolver;
         XmlReader render = XmlReader.Create(dialog.FileName, settings);
         try
         {
             try
             {
                 xmldoc.Load(render);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(this, ex.Message, "Parse Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
         }
         finally
         {
             render.Close();
         }
         GridBuilder builder = new GridBuilder();
         if (xmlGrid.ShowColumnHeader)
         {
             GridCellGroup xmlgroup = new GridCellGroup();
             xmlgroup.Flags = GroupFlags.Overlapped | GroupFlags.Expanded;
             builder.ParseNodes(xmlgroup, null, xmldoc.ChildNodes);
             GridCellGroup root = new GridCellGroup();
             root.Table.SetBounds(1, 2);
             root.Table[0, 0] = new GridHeadLabel();
             root.Table[0, 0].Text = dialog.FileName;
             root.Table[0, 1] = xmlgroup;
             xmlGrid.Cell = root;
         }
         else
         {
             GridCellGroup root = new GridCellGroup();
             builder.ParseNodes(root, null, xmldoc.ChildNodes);
             xmlGrid.Cell = root;
         }
     }
 }
開發者ID:zippy1981,項目名稱:XmlGridControl,代碼行數:51,代碼來源:Form1.cs

示例15: FindDiscount

 /// <summary>
 /// Find the discount percentage applicable to the user
 /// </summary>
 /// <returns>Discount percentage</returns>
 public int FindDiscount()
 {
     int discountPercentage = 0;
     try
     {
         XmlDataDocument xmldoc = new XmlDataDocument();
         XmlNodeList xmlnode;
         if (user is Employee)
         {
             FileStream fs = new FileStream(Directory.GetCurrentDirectory() + "\\ApplicableDiscounts\\EmployeeDiscount.xml", FileMode.Open, FileAccess.Read);
             xmldoc.Load(fs);
             xmlnode = xmldoc.GetElementsByTagName("Discount");
             String discount = xmlnode[0].FirstChild.Value;
             discountPercentage = Int32.Parse(discount);
         }
         if (user is Affiliate)
         {
             FileStream fs = new FileStream(Directory.GetCurrentDirectory() + "\\ApplicableDiscounts\\AffiliateDiscount.xml", FileMode.Open, FileAccess.Read);
             xmldoc.Load(fs);
             xmlnode = xmldoc.GetElementsByTagName("Discount");
             String discount = xmlnode[0].FirstChild.Value;
             discountPercentage = Int32.Parse(discount);
         }
         if (user is Customer && (user as Customer).AssociatedSinceYears >= 2)
         {
             FileStream fs = new FileStream(Directory.GetCurrentDirectory() + "\\ApplicableDiscounts\\CustomerDiscount.xml", FileMode.Open, FileAccess.Read);
             xmldoc.Load(fs);
             xmlnode = xmldoc.GetElementsByTagName("Discount");
             String discount = xmlnode[0].FirstChild.Value;
             discountPercentage = Int32.Parse(discount);
         }
     }
     catch(Exception ex)
     {
         Console.WriteLine("Exception while loading xml data for discount specific to to the type of user");
     }
     return discountPercentage;
 }
開發者ID:vinayv1234,項目名稱:Discount,代碼行數:42,代碼來源:DiscountReader.cs


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