?
Solved

convert this xml into csv file

Posted on 2014-03-14
4
Medium Priority
?
118 Views
Last Modified: 2016-04-06
See the attached file. I need to convert this into a csv file, where each row is an employee record.

I need this done in C#, can someone please help???
EMPDETP---Test-Data.xml
0
Comment
Question by:dipster307
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
4 Comments
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 39929581
A typical CSV file only has a single record type, your XML file has two of them (presumably parent child).

Do you want company and employee lines interspersed?

Suppose there is more than one PAGE, do we just ignore pages?
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 39929584
Or maybe we just ignore company lines and do employee lines, that is what you seem to be asking for....do you need a header line in the CSV output?
0
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 2000 total points
ID: 39929760
With no header lines and only employee data lines, you could use:

            var doc = new XmlDocument();
            doc.Load("data.xml");
            var columns = doc.SelectNodes("//COLUMNS[COLUMN/@NAME=\"Employees.Reference\"]");
            var x = String.Join(Environment.NewLine, from XmlNode record in columns
                                                     select
                                                         String.Join(",", (from XmlNode column in record.SelectNodes("COLUMN")
                                                                           select column.InnerText)));
            Console.Write(x);

Open in new window

0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 39929762
(I filter for Employees.Reference to avoid output of any Company data)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question