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


C# XmlDocument.LoadXml方法代码示例

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


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

示例1: LoadConfig

    IEnumerator LoadConfig()
    {
        Debug.Log("WeaveAppLoader -> LoadConfig()");

        XmlDocument config = new XmlDocument();

        if(_filePath == "") {
            // Load from Resources

            Debug.Log("Loading From Resources");
            TextAsset textAsset = (TextAsset)Resources.Load("config/weave_config");
            config.LoadXml(textAsset.text);

        } else {
            string url = _filePath + "config/weave_config.xml";
            WWW www = new WWW(url);
            yield return www;

            if(www.error == null) {
                Debug.Log("Loading weave_config.xml from filePath");
                string xml = www.text;
                config.LoadXml(xml);
            } else {
                Debug.Log("Error: " +www.error +" - loading from resources");

                TextAsset textAsset = (TextAsset)Resources.Load("config/weave_config.xml");
                config.LoadXml(textAsset.text);
            }
        }

        DataModel.Instance.Config = config;

        StartCoroutine(LoadPeople());
    }
开发者ID:stubuchbinder,项目名称:weave,代码行数:34,代码来源:WeaveAppLoader.cs

示例2: btnImportData_Click

    //导入数据库
    protected void btnImportData_Click(object sender, EventArgs e)
    {
        string xml = txtData.Value.Trim();
        if (string.IsNullOrEmpty(xml))
        {
            Common.MessageBox.Show(this, "文本框为空!");
            return;
        }
        try
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xml); //加载XML文档

            XmlNode root = xmlDoc.SelectSingleNode("//config");
            InsertTableData(xmlDoc, "webconfig");
            InsertTableData(xmlDoc, "dictionary");
            InsertTableData(xmlDoc, "channel");
            InsertTableData(xmlDoc, "ad");
            InsertTableData(xmlDoc, "adtype");
            Common.MessageBox.Show(this, "成功导入数据库!");
        }
        catch (Exception ex)
        {
            Common.MessageBox.Show(this, ex.Message);
        }
    }
开发者ID:fsfree,项目名称:dookcms,代码行数:27,代码来源:inout.aspx.cs

示例3: GetUpdateList

    private void GetUpdateList(string updateKey)
    {
        WebClient client = new WebClient();
        client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";

        string response;

        try
        {
            response = client.UploadString("http://infinity-code.com/products_update/checkupdates.php",
            "k=" + WWW.EscapeURL(updateKey) + "&v=" + OnlineMaps.version + "&c=" + (int)channel);
        }
        catch
        {
            return;
        }
        
        XmlDocument document = new XmlDocument();
        document.LoadXml(response);

        XmlNode firstChild = document.FirstChild;
        updates = new List<OnlineMapsUpdateItem>();

        foreach (XmlNode node in firstChild.ChildNodes) updates.Add(new OnlineMapsUpdateItem(node));
    }
开发者ID:juliancruz87,项目名称:transpp,代码行数:25,代码来源:OnlineMapsUpdater.cs

示例4: GetData

    public void GetData()
    {
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.LoadXml(LevelStats.text);

        StartCoroutine(LoadLevelStats(xmlDoc));
    }
开发者ID:SeniorTeam,项目名称:MonkeyHead,代码行数:7,代码来源:LevelManager.cs

示例5: SetCountriesName

    public static void SetCountriesName(string language)
    {
        Debug.Log("countries....." +  language);
        TextAsset textAsset = (TextAsset) Resources.Load("countries");
        var xml = new XmlDocument ();
        xml.LoadXml (textAsset.text);

        Countries = new Hashtable();
        AppCountries = new SortedList();

        try{
            var element = xml.DocumentElement[language];
            if (element != null) {
                var elemEnum = element.GetEnumerator();
                while (elemEnum.MoveNext()) {
                    var xmlItem = (XmlElement)elemEnum.Current;
                    Countries.Add(xmlItem.GetAttribute("name"), xmlItem.InnerText);
                    AppCountries.Add(xmlItem.GetAttribute("name"), xmlItem.InnerText);
                }
            } else {
                Debug.LogError("The specified language does not exist: " + language);
            }

        }
        catch (Exception ex)
        {
            Debug.Log("Language:SetCountryName()" + ex.ToString());
        }
    }
开发者ID:jmoraltu,项目名称:KatoizApp,代码行数:29,代码来源:Language.cs

示例6: DL_newslist_ItemDatabound

    protected void DL_newslist_ItemDatabound(object sender, ListViewItemEventArgs e)
    {
        if (e.Item.ItemType == ListViewItemType.DataItem)
        {
            ListViewDataItem ditem = (ListViewDataItem)e.Item;
            //data reader
            System.Data.DataRowView item = (System.Data.DataRowView)ditem.DataItem;

            HyperLink NewsTitle = (HyperLink)ditem.FindControl("NewsTitle");
            Literal NewsDate = (Literal)ditem.FindControl("NewsDate");

            XmlDocument XMLDoc = new XmlDocument();
            XMLDoc.LoadXml(item["content_html"].ToString());

            string HeadLine = commonfunctions.getFieldValue(XMLDoc, "Headline", "/News");
            string Date = commonfunctions.getFieldValue(XMLDoc, "Date", "/News");
            string Teaser = commonfunctions.getFieldValue(XMLDoc, "Teaser", "/News");

            DateTime DateShown = Convert.ToDateTime(Date);
            long newsId = long.Parse(item["content_id"].ToString());
            NewsDate.Text = DateShown.ToString("MMMM dd, yyyy");

            NewsTitle.Text = HeadLine;
            NewsTitle.NavigateUrl = commonfunctions.getQuickLink(newsId); ;

        }
    }
开发者ID:femiosinowo,项目名称:sssadl,代码行数:27,代码来源:NewsList4.aspx.cs

示例7: GetAttributesOnTextNode

        public static void GetAttributesOnTextNode()
        {
            var xmlDocument = new XmlDocument();
            xmlDocument.LoadXml("<a>text node</a>");

            Assert.Null(xmlDocument.DocumentElement.FirstChild.Attributes);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:AttributesTests.cs

示例8: GetAttributesOnProcessingInstruction

        public static void GetAttributesOnProcessingInstruction()
        {
            var xmlDocument = new XmlDocument();
            xmlDocument.LoadXml("<a><?PI pi_info?></a>");

            Assert.Null(xmlDocument.DocumentElement.FirstChild.Attributes);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:AttributesTests.cs

示例9: LoadDataString

    public static string LoadDataString(string s)
    {
        XmlDocument doc = new XmlDocument ();
        doc.LoadXml (s);

        return doc.OuterXml;
    }
开发者ID:moriz1,项目名称:CordycepSim,代码行数:7,代码来源:XMLHandler.cs

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

示例11: getConfigItem

    public static String getConfigItem(String id)
    {
        String s_return = "";
        if (tools.configXML == null || id.Equals("reLoad"))
        {
            tools.dbType = null;
            tools.configXML = null;
            String path = tools.webPath + "\\config.xml";
            TextReader fr = new StreamReader(path);
            String strLine = fr.ReadLine();
            String xml = "";
            while (strLine != null)
            {
                xml += strLine;
                strLine = fr.ReadLine();
            }

            configXML = new XmlDocument();
            configXML.LoadXml(xml);
            tools.dbType = tools.getConfigItem("DB_TYPE");
        }
        XmlElement e = configXML.GetElementById(id);
        s_return = e.InnerText;
        return s_return;
    }
开发者ID:noikiy,项目名称:ligerui-net-demo,代码行数:25,代码来源:tools.cs

示例12: ParsePListFile

 public static bool ParsePListFile(string xmlFile, ref Hashtable plist)
 {
     /*
     if (!File.Exists(xmlFile)) {
         Debug.LogError("File doesn't exist: " + xmlFile);
         return false;
     }
     StreamReader sr = new StreamReader(xmlFile);
     string txt = sr.ReadToEnd();
     sr.Close();
     */
     string txt = xmlFile;
     XmlDocument xml = new XmlDocument();
             xml.XmlResolver = null; //Disable schema/DTD validation, it's not implemented for Unity.
     xml.LoadXml(txt);
     XmlNode plistNode = xml.LastChild;
     if (!plistNode.Name.Equals("plist")) {
         Debug.LogError("plist file missing <plist> nodes." + xmlFile);
         return false;
     }
     string plistVers = plistNode.Attributes["version"].Value;
     if (plistVers == null || !plistVers.Equals(SUPPORTED_VERSION)) {
         Debug.LogError("This is an unsupported plist version: " + plistVers + ". Required version:a " + SUPPORTED_VERSION);
         return false;
     }
     XmlNode dictNode = plistNode.FirstChild;
     if (!dictNode.Name.Equals("dict")) {
         Debug.LogError("Missing root dict from plist file: " + xmlFile);
         return false;
     }
     return LoadDictFromPlistNode(dictNode, ref plist);
 }
开发者ID:rahmanazhar,项目名称:UnityWorkspace,代码行数:32,代码来源:PListManager.cs

示例13: ElementWithNoChildTwoAttributes

        public static void ElementWithNoChildTwoAttributes()
        {
            var xmlDocument = new XmlDocument();
            xmlDocument.LoadXml("<top attr1='test1' attr2='test2' />");

            Assert.Null(xmlDocument.DocumentElement.FirstChild);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:7,代码来源:FirstChildTests.cs

示例14: ElementWithNoChild

        public static void ElementWithNoChild()
        {
            var xmlDocument = new XmlDocument();
            xmlDocument.LoadXml("<top />");

            Assert.Null(xmlDocument.DocumentElement.FirstChild);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:7,代码来源:FirstChildTests.cs

示例15: xmltranslate

    public void xmltranslate(string url, string queryString)
    {
        HttpRequest Request = HttpContext.Current.Request;
        string callback = Request["callback"];
        HttpContext.Current.Response.ContentType = "application/json;charset=utf-8";
        HttpResponse Response = HttpContext.Current.Response;

           // string url = "http://www.tianditu.com/query.shtml?";
           // string queryString = "postStr={'orig':'116.35506,39.92277','dest':'116.39751,39.90854','mid':'116.36506,39.91277;116.37506,39.92077','style':'0'}&type=search";
        HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url + queryString);
        httpWebRequest.ContentType="text/xml";
        httpWebRequest.Method="GET";
        HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
        StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream());
        string responseContent = streamReader.ReadToEnd();
        httpWebResponse.Close();
        streamReader.Close();

        XmlDocument doc = new XmlDocument();
        doc.LoadXml(responseContent);
        string json = JsonConvert.SerializeXmlNode(doc);
        //return json;
        Response.Write(callback + "("  + json  + ")"); ;
        Response.End();
    }
开发者ID:jijingyu1991,项目名称:github_Elecmap,代码行数:25,代码来源:WebService.cs


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