XML 问题 (回复者请将所要分数写在回复下面,调试通过马上给分。)

天缘阁 2005-02-27 07:25:47
<?xml version="1.0"?>
<!--Configuration Files Information-->
<CONFIGINFO CreateDate="2005-2-27 18:51:44">
<Info>XMLApp</Info>
</CONFIGINFO>
创建这样的上面文件。
再添加下面的节点。
<TEST TestInfo="。。。。。">
<Info>WWW</Info>
</TEST>

上面 XML 文件,用C#怎样写。 谢谢!
...全文
117 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
天缘阁 2005-02-27
  • 打赏
  • 举报
回复
我给你发了个消息 看看吧 我结贴了 谢谢了
天缘阁 2005-02-27
  • 打赏
  • 举报
回复
那 我想用xml模拟INI 我改怎么做
可以告诉我吗
放心 分一定会给 这是宗旨 也是原则
你QQ多少 加你
AllenTing 2005-02-27
  • 打赏
  • 举报
回复
当然不行!!
xml必须有且只有一个root元素
天缘阁 2005-02-27
  • 打赏
  • 举报
回复
<?xml version="1.0"?>
<!--Configuration Files Information-->
<CONFIGINFO CreateDate="2005-2-27 18:51:44">
<Info>XMLApp</Info>
</CONFIGINFO>
<TEST TestInfo="。。。。。">
<Info>WWW</Info>
</TEST>
我要的是这个样子的 可以写吗 是不是不符合 xml 规则
AllenTing 2005-02-27
  • 打赏
  • 举报
回复
忘了说了,我要100分!
呵呵
AllenTing 2005-02-27
  • 打赏
  • 举报
回复
1 XmlTextWriter myXmlTextWriter = new XmlTextWriter ("aaa.xml", null);
myXmlTextWriter.Formatting = Formatting.Indented;
myXmlTextWriter.WriteStartDocument(false);

myXmlTextWriter.WriteComment("Configuration Files Information");

myXmlTextWriter.WriteStartElement("CONFIGINFO");
myXmlTextWriter.WriteAttributeString("CreateDate","2005-2-27 18:51:44");
myXmlTextWriter.WriteElementString("Info", "WWW");

myXmlTextWriter.WriteEndElement();
myXmlTextWriter.Flush();
myXmlTextWriter.Close();








2 XmlDocument xmlDoc=new XmlDocument();
xmlDoc.Load("aaa.xml");
XmlNode root=xmlDoc.SelectSingleNode("CONFIGINFO");
XmlElement xe1=xmlDoc.CreateElement("TEST");
xe1.SetAttribute("TestInfo","....");

XmlElement xe2=xmlDoc.CreateElement("Info");

xe2.InnerText="WWW";
xe1.AppendChild(xe2);

root.AppendChild(xe1);
xmlDoc.Save("aaa.xml");






110,529

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧