C#读取XML? [英] C# reading XML?

查看:66
本文介绍了C#读取XML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我是初学者,我在C#中读取xml时遇到了严重的问题。

这是我的XML文档:

Hello,

I''m a beginner and i got serious issues with reading xml in C#.
This is my XML doc:

展开 | 选择 | Wrap | 行号

推荐答案


您好,


我是初学者,我在C#中读取xml时遇到了严重问题。

这是我的XML文档:

Hello,

I''m a beginner and i got serious issues with reading xml in C#.
This is my XML doc:

展开 | 选择 | Wrap | 行号


亲爱的mwalts,


首先,谢谢对于您的快速回复,我们非常感谢。

您发布的代码很遗憾无效。 JIT调试捕获第36行的错误,即newWidthBox.Text = xmlwidth.InnerText;。行。

有谁知道它有什么问题吗?


问候,


Dennis
Dear mwalts,

First of all, thanks for your swift reply, its highly appreciated.
The code that you have posted unfortunately doesnt work. JIT debug catches errors at line 36, which is the "newWidthBox.Text = xmlwidth.InnerText;" line.
Does anyone know what is wrong with it?

Regards,

Dennis



亲爱的mwalts,


首先,感谢您的快速回复,非常感谢。

遗憾的是,您发布的代码无效。 JIT调试捕获第36行的错误,即newWidthBox.Text = xmlwidth.InnerText;。行。

有谁知道它有什么问题吗?


问候,


Dennis
Dear mwalts,

First of all, thanks for your swift reply, its highly appreciated.
The code that you have posted unfortunately doesnt work. JIT debug catches errors at line 36, which is the "newWidthBox.Text = xmlwidth.InnerText;" line.
Does anyone know what is wrong with it?

Regards,

Dennis



错误信息是什么? xmlwidth对象是null / empty吗?

如果我是你,我会使用SelectNode或SelectSingleNode方法从XML文件中获取值。但是,这些需要使用XPath。但在你的情况下,文件非常小,所以表达式不会太复杂。我建议你阅读w3schools.com关于XPath的教程。


一切顺利!

What''s the error message? Is the xmlwidth object null/empty?
If I were you I would use SelectNode or SelectSingleNode methods to fetch the values from the XML file. These, however require usage of XPath. But in your case the file is very small, so the expression won''t be too complex. I would suggest you read the tutorial on w3schools.com about XPath.

All the best!


这篇关于C#读取XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆