具有CSV文件值的XML到C Sharp对象 [英] XML to C Sharp Object with Value from CSV File

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

问题描述

Hello All,



我说我有这样的Mapping.xml文件

Hello All,

Let me says that I have Mapping.xml file like this

<ColumnName Mapping="HELLO LOOK FOR ME 1">COLUMNVALUE1</ColumnName>
<ColumnName Mapping="HELLO LOOK FOR ME 2">COLUMNVALUE2</ColumnName>






我有一个这样的Data.csv文件:




And I have a Data.csv file like this:

"HELLO LOOK FOR ME 1", "HELLO LOOK FOR ME 2", "I AM NOT IN MAPPING 1" ,"I AM NOT IN MAPPING 2"
467898, 4786, 222323, 4687327





要求是

1)编写一个C#代码来解析Mapping.xml

2)将COLUMNNAME映射到XML中定义的Value,Against Mapping属性。在我们的案例中HELLO LOOK FOR ME 1



所以最终结果应该是一个C#对象保存值。



Requirement is
1) Write a C# Code to Parse the Mapping.xml
2) Map the COLUMNNAME to the Value, Against Mapping attribute defined in the XML. In our case "HELLO LOOK FOR ME 1"

So the End Result should be having a C# Object holding the values.

COLUMNVALUE1 = 467898
COLUMNVALUE2 = 4786







3)后者如果我希望包含第三列,我只需编辑XML文件映射文件夹




3) Latter if I wish to Included Third Column, I have to just edit the XML File Mapping.xml

<ColumnName Mapping="HELLO LOOK FOR ME 1">COLUMNVALUE1</ColumnName>
<ColumnName Mapping="HELLO LOOK FOR ME 2">COLUMNVALUE2</ColumnName>
<ColumnName Mapping="I AM NOT IN MAPPING 1">COLUMNVALUE3</ColumnName>





因此在修改后我应该在C#中有一个具有值的对象





So that after the modification I should have a Object in C# having value

COLUMNVALUE1 = 467898
COLUMNVALUE2 = 4786
COLUMNVALUE3 = 222323





这可能与C#

请注意,我知道如何解析read /编写XML文件并解析CSV文件。通过C#

但问题是,我在寻找适合我要求的C#技术。



如果有人知道或有一些想法,请让我知道



谢谢和问候

Durai Velan C



Is this possible with C#
Kindly note, I know how to parse read/write an XML file and also Parse the CSV Files. via C#
But the problem, here is I am looking for a Technique in C# that would suit my requirements.

If anyone know or have some idea kindly let me know

Thanks and Regards
Durai Velan C

推荐答案

我们不做你的作业:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!



是的,它可以在C#中使用,就像任何其他语言一样。



否则,告诉我们你做了什么并解释你的问题在哪里,你可以得到帮助。
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

Yes it is possible in C#, just like about any other language.

Otherwise, show us what you have done and explain where is your problem, you may get help.


这篇关于具有CSV文件值的XML到C Sharp对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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