myDocument.Load(Server.MapPath("contents.xml"));
XmlElement topiclist=(XmlElement)myDocument.GetElementsByTagName("topiclist");
XmlElement topic=myDocument.CreateElement("topic");
XmlElement title= topic.CreateElement("title");
title.InnerText=title;
topic.AppendChild(title);
xmlElement href=topic.CreateElement("href");
href.InnerText=href;
topic.AppendChild(href);
topiclist.PrependChild(topic);
myDocument.Save(Server.MapPath("contents.xml")); c:\inetpub\wwwroot\SVG\WebForm2.aspx.cs(75): 无法将类型“System.Xml.XmlNodeList”转换为“System.Xml.XmlElement”
c:\inetpub\wwwroot\SVG\WebForm2.aspx.cs(75): “System.Xml.XmlElement”并不包含对“CreateElement”的定义
c:\inetpub\wwwroot\SVG\WebForm2.aspx.cs(76): 无法将类型“System.Xml.XmlElement”隐式转换为“string”
c:\inetpub\wwwroot\SVG\WebForm2.aspx.cs(78): 找不到类型或命名空间名称“xmlElement”(是否缺少 using 指令或程序集引用?)请问一下怎么改!!
XmlElement topiclist=(XmlElement)myDocument.GetElementsByTagName("topiclist");
XmlElement topic=myDocument.CreateElement("topic");
XmlElement title= topic.CreateElement("title");
title.InnerText=title;
topic.AppendChild(title);
xmlElement href=topic.CreateElement("href");
href.InnerText=href;
topic.AppendChild(href);
topiclist.PrependChild(topic);
myDocument.Save(Server.MapPath("contents.xml")); c:\inetpub\wwwroot\SVG\WebForm2.aspx.cs(75): 无法将类型“System.Xml.XmlNodeList”转换为“System.Xml.XmlElement”
c:\inetpub\wwwroot\SVG\WebForm2.aspx.cs(75): “System.Xml.XmlElement”并不包含对“CreateElement”的定义
c:\inetpub\wwwroot\SVG\WebForm2.aspx.cs(76): 无法将类型“System.Xml.XmlElement”隐式转换为“string”
c:\inetpub\wwwroot\SVG\WebForm2.aspx.cs(78): 找不到类型或命名空间名称“xmlElement”(是否缺少 using 指令或程序集引用?)请问一下怎么改!!
<?xml version="1.0" encoding="GB2312"?>
<topiclist type="AspCool News">
<topic>
<title>第一条新闻</title>
<href>main.aspx?name=news1</href>
</topic>
<topic>
<title>第二条新闻</title>
<href>main.aspx?name=new2</href>
</topic>
</topiclist>
查msdn帮助吧