本文整理汇总了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());
}
示例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);
}
}
示例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));
}
示例4: GetData
public void GetData()
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(LevelStats.text);
StartCoroutine(LoadLevelStats(xmlDoc));
}
示例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());
}
}
示例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); ;
}
}
示例7: GetAttributesOnTextNode
public static void GetAttributesOnTextNode()
{
var xmlDocument = new XmlDocument();
xmlDocument.LoadXml("<a>text node</a>");
Assert.Null(xmlDocument.DocumentElement.FirstChild.Attributes);
}
示例8: GetAttributesOnProcessingInstruction
public static void GetAttributesOnProcessingInstruction()
{
var xmlDocument = new XmlDocument();
xmlDocument.LoadXml("<a><?PI pi_info?></a>");
Assert.Null(xmlDocument.DocumentElement.FirstChild.Attributes);
}
示例9: LoadDataString
public static string LoadDataString(string s)
{
XmlDocument doc = new XmlDocument ();
doc.LoadXml (s);
return doc.OuterXml;
}
示例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);
}
}
示例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;
}
示例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);
}
示例13: ElementWithNoChildTwoAttributes
public static void ElementWithNoChildTwoAttributes()
{
var xmlDocument = new XmlDocument();
xmlDocument.LoadXml("<top attr1='test1' attr2='test2' />");
Assert.Null(xmlDocument.DocumentElement.FirstChild);
}
示例14: ElementWithNoChild
public static void ElementWithNoChild()
{
var xmlDocument = new XmlDocument();
xmlDocument.LoadXml("<top />");
Assert.Null(xmlDocument.DocumentElement.FirstChild);
}
示例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();
}