如何在xml文件中添加带超链接的节点 [英] How to add node with hyperlink in xml file

查看:1081
本文介绍了如何在xml文件中添加带超链接的节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



Plz建议如何在xml文件中添加带超链接的节点

Dear all,

Plz suggest how can i add node with hyperlink in xml file

推荐答案

// Create an XML document instance, and load XML data.
            XmlDocument doc = new XmlDocument();
            doc.Load(Server.MapPath(".") + @"\test17.xml");                      // This code assumes that the XML file is in the same folder.


        //http://support.microsoft.com/kb/317664
          //http://support.microsoft.com/kb/317666
          // A. Addition
          // 1. Create a new item element.
          XmlElement newElem = doc.CreateElement("item");


          // Create the child nodes. This code demonstrates various ways to add them.
          newElem.InnerXml = "<title></title><link></link><description></description><pubdate></pubdate>";
          newElem["link"].InnerText = "title";
          newElem["link"].InnerText = "url";
          newElem["description"].InnerText = "<![CDATA[ " + "strdes" + " ";
          newElem["pubDate"].InnerText = System.DateTime.Now.ToString("r");


          // 2.  Add the new element to the end of the item list.
          doc.DocumentElement.SelectNodes("/rss/channel")[0].AppendChild(newElem);


          // 3. Save the modified XML to a file in Unicode format.
          doc.PreserveWhitespace = true;
          XmlTextWriter wrtr = new XmlTextWriter(@"c:\test.xml", System.Text.Encoding.Unicode);
          doc.WriteTo(wrtr);
          wrtr.Close();





参考链接



http://forums.asp.net/t/1062335.aspx/1 [ ^ ]


你你可以像在html中那样做;毕竟,html是xml的一个卑鄙子集。



< a href =http://www.codeproject.com>链接< / a>
You do it the same way you do in html; after all, html is a bastardized subset of xml.

<a href="http://www.codeproject.com"> A link </a>


这篇关于如何在xml文件中添加带超链接的节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆