xml 到文本框
我正在构建一个 Web 应用程序,我必须从配置文件中读取一些值,我假设该文件只是一个 XML 文件。因此,在此过程中,我可以使用“
XDocument config = XDocument.Load("\\path\to\example.exe.config");
现在我的网页中有一个文本框”来读取 XML 文档。我想在该文本框中获取特定值,用户可以在文本框中编辑和更新该值。
任何人都可以指导我找到解决方案吗?
使用 C#、Linq to XML、Asp.net
I am building a web application where I have to read some values from the config file which I am assuming as nothing but an XML file. So in this process I am able to read the XML document using
XDocument config = XDocument.Load("\\path\to\example.exe.config");
Now I have a textbox in my web page. I want to get a specific value into that textbox where the user can edit and update that value in the textbox.
Can any one guide me to the solution?
Using C#, Linq to XML, Asp.net
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,您有一个
XDocument
,因此您可以使用 Linq to XML 来查询它的值。渲染页面时将其放入文本框中。当然,当您 POST 该值时,您必须再次加载该文件,再次查询XDocument
,然后在保存之前使用新值更新 XML 元素。Well you have an
XDocument
, so you can use Linq to XML to query it for the value. Put that in the textbox when the page is rendered. Of course when you POST the value you'll have to load the file a second time, query theXDocument
again, and then update the XML element with the new value before saving.