从xml文件中读取数据 [英] Reading data from xml file

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

问题描述

嗨我在阅读xml文件时遇到问题。我想要阅读的内容是:



"cmpd_name","cmpdnr","rt","mz","i", "a","sn","z"。



这里每个"mz","i"," ; A"," SN"在"cmpd_name"下的不同行中(如果您看到附加的xml文件,将会很清楚)。在"cmpd_name"下的这些("mz","i","a","sn")
值中的每一个都是应该用","分隔。并且应该在表格中存储在单个单元格中。



例如第一个表格"cmpd_name"应如下所示:
$


这是表中的单行和不同列,我想分开  "mz"和"i"基于"z"的值。它们属于同一属性

Hi I have problem in reading xml file. The things what I want to read is :

"cmpd_name","cmpdnr","rt","mz","i","a","sn","z".

Here there may be several values for each "mz","i","a","sn" in different lines under a "cmpd_name" (It will be clear if you see the attched xml file). Each of these ("mz","i","a","sn") values under a "cmpd_name" should be seperated by "," and should store in the table in a single cell.

for example that table for first "cmpd_name" should look like this:

This is a single row and different columns in the table and I want to separate  the "mz" and "i" values based on "z" which are in the same attribute


  mz         i   a       sn   z
1. 285.13449609, 4896.99, 15532.5,2415.5 6.409,1 1
286.13775204 764.038
2. 285.13449609, 4896.99, 15532.5,2415.5 6.409,1 2
286.13775204 764.038

推荐答案

一些建议:

1)使用< />工具栏中的按钮,用于插入代码的帖子。它将保留其格式。

1) Use the </> button in the toolbar for the post to insert your code. It will retain its formatting.

2)尝试将提供的代码缩减到足以显示问题的问题。

2) Try to scale back the provided code to just enough to show the problem question.

3)哪个版本您正在使用Visual Studio吗? XDocument(VS 2008中的新增功能)比XmlDocument更容易使用。

3) Which version of Visual Studio are you using? XDocument (new in VS 2008) is much easier to use than XmlDocument.

以下是使用XDocument访问XML文件的链接:

Here is a link to accessing an XML file using XDocument:

< a href ="http://msmvps.com/blogs/deborahk/archive/2010/06/06/reading-an-xml-file.aspx"> http://msmvps.com/blogs/deborahk/archive/2010 /06/06/reading-an-xml-file.aspx

希望这会有所帮助。


这篇关于从xml文件中读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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