Click here to Skip to main content
15,896,410 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
Dear all,

Plz suggest how can i add node with hyperlink in xml file
Posted
Comments
johnmcpherson10 28-Sep-17 14:24pm    
Don't even read this, not a solution. Just a bogus answer...

C#
// 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();


reference link

http://forums.asp.net/t/1062335.aspx/1[^]
 
Share this answer
 
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>
 
Share this answer
 
Comments
srikanth_p05 9-Jul-13 6:58am    
it is not working at all
H.Brydon 9-Jul-13 10:54am    
Perhaps you have some characters in the url that need to be escaped. If you have "&", "\", "/" (and several others), you need to escape them. Try your logic with a simple url first, then the more complicated one after that works.

What does the url look like when you extract it from the xml? How are you extracting the data from the xml?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900