|
-
Aug 2nd, 2018, 01:56 AM
#1
Thread Starter
Junior Member
How to insert new item to channel in XML file
I want to insert new element inside <channel> tag using vb code
my xml file looks like :
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
</channel>
</rss>
this is my code :
Dim root = New XElement("item")
Dim title = New XElement("title", New XCData(TextBox3.Text))
Dim link = New XElement("link", TextBox6.Text)
Dim pubDate = New XElement("pubDate", DateTime.Now.ToString("yyy/MM/dd HH:mm"))
Dim description = New XElement("description", New XCData(TextBox5.Text))
Dim thumbnail = New XElement("media.thumbnail",
New XAttribute("url", "http://karary-001-site1.htempurl.com/files/" + attac1 + "?itok=YdFLolAU"),
New XAttribute("height", 266),
New XAttribute("width", 127))
root.Add(title, link, pubDate, description, thumbnail)
document.Root.Add(root)
document.Save(FilePath)
my code add new items after channel and rss tag end !!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|