asp.net - 在 web 上的 xml 文件中插入数据
问题描述
我正在尝试在我的 xml 文件中的特定标签之间插入数据,该代码在我的计算机上运行良好,但是当我在网络上运行它时,它不会像这样在特定标签之间插入数据:这是我的 xml 文件:
<?xml version='1.0' encoding='utf-8'?>
<rss version='2.0' xmlns:media='http://search.yahoo.com/mrss/'>
<channel>
</channel>
</rss>
我想在“通道”标签内插入数据。这是我的代码,它工作正常!:
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"
当我更改 FilePath ="C:\Users\MONZER\Downloads\XMLFile1.xml" 时:我明白了:
<?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>
但是当我使用 FilePath ="h:\root\home\karary-001\www\site1\xmlfile1.xml" 时:我明白了:
<?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>
解决方案
推荐阅读
- r - R中泊松模型的预测性能
- agora.io - 抓麦克风和麦克风掉落时如何解决集市中的轨道禁用错误?
- python - Python中的顺序函数IO设计模式
- java - 多次发送同一个请求,使用不同的参数,由于第一次请求响应而发送另一个请求
- r - For - 循环遍历行和列,填充一个空数据帧,具体取决于另一个数据帧 (r) 的值
- android - 目标需要一个项目来执行但是这个目录中没有POM但是目录中有POM文件
- javascript - React 的 Plotly.js uirevision 不起作用
- html - 如何让文本溢出在具有动态宽度的容器中工作?
- terraform - 如何忽略terraform中的块
- apache - 从 Apache 到 Nginx 的 Imperva WAF X-Forwarded-For HTTP Header 的某个指南需要解释