本文整理汇总了C#中XmlDocument.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDocument.ToString方法的具体用法?C# XmlDocument.ToString怎么用?C# XmlDocument.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlDocument
的用法示例。
在下文中一共展示了XmlDocument.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load(MapPath("ComicReviews.xml"));
//XmlElement elem = doc.CreateElement("test");
//elem.InnerText = "it worked!";
//XmlNode oldCd;
XmlElement root = doc.DocumentElement;
//oldCd = root.SelectSingleNode("/catalog/cd[title='Hide your heart']");
XmlElement newCd = doc.CreateElement("ComicReview");
//newCd.SetAttribute("country", "Country.text");
newCd.InnerXml = "<ComicName>" + txtComicName.Text + "</ComicName> <ReviewerName>" + txtReviewer.Text + "</ReviewerName> <Rating>" + txtRating.Text + "</Rating> <Genre1>" + txtGenre1.Text + "</Genre1> <Genre2>" + txtGenre2.Text + "</Genre2> <Status>" + txtURL.Text + "</Status> <Quality>" + txtQuality.Text + "</Quality>";
//root.ReplaceChild(newCd, oldCd);
root.PrependChild(newCd);
Response.Write(doc.ToString());
doc.Save(MapPath("ComicReviews.xml"));
}
示例2: getShortcutData
public static List<ShortcutData> getShortcutData()
{
Debug.Log("Reading xml");
XmlDocument xml = new XmlDocument();
try{
xml.Load(configPath+shortcutConfig);
}
catch(Exception)
{
createConfig();
return getShortcutData();
}
List<ShortcutData> data = new List<ShortcutData>();
ShortcutData d;
Debug.Log(xml.ToString());
foreach(XmlNode n1 in xml.FirstChild.ChildNodes)
{
//Debug.Log(n1.Name+"/"+n1.InnerXml);
d = new ShortcutData();
int x = -1;
int y = -1;
int wall = -1;
foreach(XmlNode n2 in n1.ChildNodes)
{
switch(n2.Name)
{
case "name":
d.name = n2.InnerText;
break;
case "path":
d.path = n2.InnerText;
break;
case "icon":
try
{
d.iconId = System.Convert.ToInt32(n2.InnerText);
}
catch(Exception)
{
d.loadIcon(n2.InnerText);
n2.InnerText = d.iconId.ToString ();
}
break;
case "model":
//TODO
break;
case "model_enable":
if(n2.InnerText == "true")
d.modelEnabled = true;
else d.modelEnabled = false;
break;
case "extension_standard":
if(n2.InnerText == "true")
d.modelEnabled = true;
else d.extensionStandard = false;
break;
case "x":
x = Convert.ToInt32(n2.InnerText);
break;
case "y":
y = Convert.ToInt32(n2.InnerText);
break;
case "wall":
wall = Convert.ToInt32(n2.InnerText);
break;
}
}
if(x != -1 && y != -1 && wall != -1)
d.setPosition(wall,x,y,false);
data.Add(d);
}
xml.Save(configPath+shortcutConfig);
currentConfig = data;
return data;
}