写入xml格式问题 <outer_id action="delete">10243</outer_id> xml输出这样的格式,请问写入的时候该怎么写?谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <outer_id action="delete">"+ 你的值 +"</outer_id> 往网站根目录下test.xml文件里第一个person元素下插入<outer_id action="delete">10243</outer_id>XmlDocument xml = new XmlDocument(); xml.Load(Server.MapPath("~/test.xml")); XmlNode person= xml.GetElementsByTagName("person")[0]; XmlElement newElement = xml.CreateElement("outer_id"); newElement.SetAttribute("action", "delete"); newElement.InnerText = "10243"; person.AppendChild(newElement); xml.Save(Server.MapPath("~/test.xml"));也可以参考:在.NET中使用XML、读取XML文件,插入数据到XML文 操作XMl或者百度。。xmlhelper... 插入XMLpublic static void Insert(string path, string node, string element, string attribute, string value) { try { XmlDocument doc = new XmlDocument(); doc.Load(path); XmlNode xn = doc.SelectSingleNode(node); if (element.Equals("")) { if (!attribute.Equals("")) { XmlElement xe = (XmlElement)xn; xe.SetAttribute(attribute, value); } } else { XmlElement xe = doc.CreateElement(element); if (attribute.Equals("")) xe.InnerText = value; else xe.SetAttribute(attribute, value); xn.AppendChild(xe); } doc.Save(path); } catch { } } XmlDocument document = new XmlDocument(); string text = null; text += "<outer_id action="delete">"+ 你的值 +"</outer_id>"; text = text.Replace("&", "&"); document.LoadXml(@"<外层>" + text + "</外层>"); string path = "test.xml"; document.Save(HttpContext.Current.Server.MapPath(path)); ds.Dispose(); 用一个控件的高度控制另一个控件的显隐性 修改相同的字要怎么做呢 如何从sqldatasource动态sql语句中得到静态sql语句 asp.net数据绑定 数据如何同时放进主表和明细表? 谁有网页流量监控软件,给个下载地址谢谢 高分求解有关字符中取字符的问题? web.config 中的ACCESS连接句在类库中如何读出 请问各位要搭建一个Asp.NET的开发环境需要些什么软件啊? 如何写这样的webservice的方法?? 修改时为什么获取的参数为0?? asp.net 删除数据库路径和服务器文件
<outer_id action="delete">"+ 你的值 +"</outer_id>
XmlDocument xml = new XmlDocument();
xml.Load(Server.MapPath("~/test.xml"));
XmlNode person= xml.GetElementsByTagName("person")[0];
XmlElement newElement = xml.CreateElement("outer_id");
newElement.SetAttribute("action", "delete");
newElement.InnerText = "10243";
person.AppendChild(newElement);
xml.Save(Server.MapPath("~/test.xml"));
也可以参考:在.NET中使用XML、读取XML文件,插入数据到XML文
操作XMl或者百度。。xmlhelper...
public static void Insert(string path, string node, string element, string attribute, string value)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load(path);
XmlNode xn = doc.SelectSingleNode(node);
if (element.Equals(""))
{
if (!attribute.Equals(""))
{
XmlElement xe = (XmlElement)xn;
xe.SetAttribute(attribute, value);
}
}
else
{
XmlElement xe = doc.CreateElement(element);
if (attribute.Equals(""))
xe.InnerText = value;
else
xe.SetAttribute(attribute, value);
xn.AppendChild(xe);
}
doc.Save(path);
}
catch { }
}
string text = null;
text += "<outer_id action="delete">"+ 你的值 +"</outer_id>";
text = text.Replace("&", "&");
document.LoadXml(@"<外层>" + text + "</外层>");
string path = "test.xml";
document.Save(HttpContext.Current.Server.MapPath(path));
ds.Dispose();