I'm trying to insert data between specific tag inside my xml file , The code works well on my computer but when I run it on the web it Does not insert the data between the specific tag like that : this is my xml file :
I want to insert data inside "channel" tag . this is my code it's working fineCode:<?xml version='1.0' encoding='utf-8'?> <rss version='2.0' xmlns:media='http://search.yahoo.com/mrss/'> <channel> </channel> </rss>
when I change FilePath ="C:\Users\MONZER\Downloads\XMLFile1.xml" : I get this :Code:FilePath = "h:\root\home\karary-001\www\site1\xmlfile1.xml" **//this is path to my xml file on website** Dim document As New XDocument document = XDocument.Load(FilePath) Dim root = New XElement("item") Dim title = New XElement("title", New XCData(TextBox3.Text)) Dim link = New XElement("link", TextBox6.Text) root.Add(title, link) document.Root.Elements.First().Add(root) document.Save(FilePath) Label1.Text = "! done"
but when I use FilePath ="h:\root\home\karary-001\www\site1\xmlfile1.xml" : I get this :Code:<?xml version="1.0" encoding="utf-8"?> <rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/"> <channel> <item> <title><![CDATA[ title]]></title> <link>http://karary-001-site1.htempurl.com</link> <pubDate>2018/08/06 06:20</pubDate> <description><![CDATA[fsdsdsdsgntbx cfv]]></description> <media.thumbnail url="http://karary-001-site1.htempurl.com/images/" height="266" width="127" /> </item> </channel> </rss>
Code:<?xml version="1.0" encoding="utf-8"?> <rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/"> <channel></channel> <item> <title><![CDATA[ title]]></title> <link>http://karary-001-site1.htempurl.com</link> <pubDate>2018/08/06 06:20</pubDate> <description><![CDATA[fsdsdsdsgntbx cfv]]></description> <media.thumbnail url="http://karary-001-site1.htempurl.com/images/" height="266" width="127" /> </item> </rss>


Reply With Quote
