M
monzer ahmed
Guest
I want to insert new element inside tag using vb code my code add new items after channel and rss tag end !!
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 :
FilePath = "h:\root\home\ka-001\www\site1\xmlfile1.xml"
Dim document As XDocument = New XDocument()
If File.Exists(FilePath) Then
document = XDocument.Load(FilePath)
Else
Label1.Text = "! file dosn't exist"
End If
If FileUpload1.HasFile = True Then
If FileUpload1.PostedFile.ContentLength <= size Then
Dim strPath As String
strPath = "~/files/" & FileUpload1.FileName
FileUpload1.SaveAs(MapPath(strPath))
End If
End If
attac1 = FileUpload1.FileName
Dim root As XElement = New XElement("item")
Dim title As XElement = New XElement("title", New XCData(TextBox3.Text))
Dim link As XElement = New XElement("link", TextBox6.Text)
root.Add(title, link)
document.Root.Add(root)
document.Save(FilePath)
Label1.Text = "! done"
Continue reading...
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 :
FilePath = "h:\root\home\ka-001\www\site1\xmlfile1.xml"
Dim document As XDocument = New XDocument()
If File.Exists(FilePath) Then
document = XDocument.Load(FilePath)
Else
Label1.Text = "! file dosn't exist"
End If
If FileUpload1.HasFile = True Then
If FileUpload1.PostedFile.ContentLength <= size Then
Dim strPath As String
strPath = "~/files/" & FileUpload1.FileName
FileUpload1.SaveAs(MapPath(strPath))
End If
End If
attac1 = FileUpload1.FileName
Dim root As XElement = New XElement("item")
Dim title As XElement = New XElement("title", New XCData(TextBox3.Text))
Dim link As XElement = New XElement("link", TextBox6.Text)
root.Add(title, link)
document.Root.Add(root)
document.Save(FilePath)
Label1.Text = "! done"
Continue reading...