怎么给xml文档中添加数据

zz_feng 2009-01-05 11:32:33
文档名为:shell_other.xml

这是个用来播放图片用的

<?xml version="1.0"?>
<shell kt="5">
<content_name>1.jpg,2.jpg,3.jpg,4.jpg</content_name>
<path_name>content,content,content</path_name>
<link_url>http://www.lanrentuku.com/,http://www.lanrentuku.com/,http://www.lanrentuku.com/,http://www.lanrentuku.com/,http://www.lanrentuku.com/,http://www.lanrentuku.com/,http://www.lanrentuku.com/,http://www.lanrentuku.com/,http://www.lanrentuku.com/,http://www.lanrentuku.com/</link_url>
</shell>

我想每次打开网页的时候自动播放的图片名添加到该文档中。如下:
<content_name>1.jpg,2.jpg,3.jpg,4.jpg</content_name>
<path_name>content,content,content</path_name>
应该怎么添加,谢谢了。
请高手指点,多谢!
...全文
114 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunshine_anycall 2009-01-05
  • 打赏
  • 举报
回复
Linq to XML
XDocument srcTree = new XDocument(
new XComment("This is a comment"),
new XElement("Root",
new XElement("Child1", "data1"),
new XElement("Child2", "data2"),
new XElement("Child3", "data3"),
new XElement("Child2", "data4"),
new XElement("Info5", "info5"),
new XElement("Info6", "info6"),
new XElement("Info7", "info7"),
new XElement("Info8", "info8")
)
);

XDocument doc = new XDocument(
new XComment("This is a comment"),
new XElement("Root",
from el in srcTree.Element("Root").Elements()
where ((string)el).StartsWith("data")
select el
)
);
Console.WriteLine(doc);
zz_feng 2009-01-05
  • 打赏
  • 举报
回复
我怎么使用啊,上面的代码使用的时候报错!
zz_feng 2009-01-05
  • 打赏
  • 举报
回复
我怎么使用啊,上面的代码使用的时候报错!
mengxj85 2009-01-05
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 sunshine_anycall 的回复:]
Linq to XML

C# codeXDocument srcTree = new XDocument(
new XComment("This is a comment"),
new XElement("Root",
new XElement("Child1", "data1"),
new XElement("Child2", "data2"),
new XElement("Child3", "data3"),
new XElement("Child2", "data4"),
new XElement("Info5", "info5"),
new XElement("Info6", "info6"),
new XElement("I…
[/Quote]
Up
到我博客看看
wxdxy 2009-01-05
  • 打赏
  • 举报
回复
xnode类

62,269

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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