使用C#进行XML解析 [英] XML Parsing with C#
本文介绍了使用C#进行XML解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一些帮助,我在互联网上找到了一些代码块来读取和写入xml节点,这一切都很好,但不适用于xml,如下所示:
< account balance =''4930''/>(代码标签不起作用:S)
仅xml格式如下:
<帐户><余额> 4930</余额</account>
现在,问题是,我需要一些帮助,或者找到一个代码片段或一个类,或者编写自己的一个可以从节点读取值的类.
在此先感谢:)
-Adam
解决方案
您需要查找帐户节点,然后使用node.Attributes ["balance"].Value来访问属性中的值. /blockquote>
I need some help, i''ve found a few code blocks over the internet to read and write xml nodes, it''s fine and all, but doesn''t work for xml like this:
<account balance=''4930'' />(Code tags aren''t working :S)
only xml formatted like this:
<account><balance>4930</balance></account>
Now, the question, I need some help either to find a code snippet or a class, or write my own one, that can read the values from the nodes.
Thanks in advanced :)
-- Adam解决方案You need to look for the account node, then use node.Attributes["balance"].Value to access the value in the attribute.
这篇关于使用C#进行XML解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文