Are you looking for right? Are you also searching for a topic Part 5 Transforming XML to CSV using LINQ to XML? If this is the case then please see it right here
Mục lục bài viết
| Website information internet tips.
[button size=”medium” style=”primary” text=”WATCH VIDEO BELOW” link =”” target=””]
Text version of the video
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
Slides
LINQ to SQL Tutorial – All Text Articles & Slides
LINQ to XML Tutorial Playlist
Dot Net, SQL, Angular, JavaScript, jQuery and Bootstrap complete courses
In your application there may be a need to transform an XML document into
1. CSV format
2. HTML format
3. Different XML format
In this video, we will discuss transforming the following XML document into CSV format.
[?xml version=”1.0″ encoding=”utf-8″?]
[Students]
[Student Country=”USA”]
[Name]Mark[/Name]
[Gender]Male[/Gender]
[TotalMarks]800[/TotalMarks]
[/Student]
[Student Country=”USA”]
[Name]Rosy[/Name]
[Gender]Female[/Gender]
[TotalMarks]900[/TotalMarks]
[/Student]
[Student Country=”India”]
[Name]Pam[/Name]
[Gender]Female[/Gender]
[TotalMarks]850[/TotalMarks]
[/Student]
[Student Country=”India”]
[Name]John[/Name]
[Gender]Male[/Gender]
[TotalMarks]950[/TotalMarks]
[/Student]
[/Students]
After transformation, data in the CSV file should look as shown below.
USA,Mark,Male,800
USA,Rosy,Female,900
India,Pam,Female,850
India,John,Male,950
Code to transform XML to CSV
StringBuilder sb = new StringBuilder();
string delimiter = “,”;
XDocument.Load(@”C:DemoDemoData.xml”).Descendants(“Student”)
.ToList().ForEach(element =]sb.Append(
element.Attribute(“Country”).Value + delimiter +
element.Element(“Name”).Value + delimiter +
element.Element(“Gender”).Value + delimiter +
element.Element(“TotalMarks”).Value + “rn”));
StreamWriter file = new StreamWriter(@”C:DemoDemoResult.csv”);
file.WriteLine(sb.ToString());
file.Close(); ..
You can also view more information regarding Tutorials about the game by us here: https://bem2.vn/
You can read more information tips here:See more here.
convert xml to csv using c#,convert xml to csv,xml tranformation,linq to xml,linq to xml c#,dot net,.net,XML (Programming Language),Language Integrated Query (Programming Language).
#Part #Transforming #XML #CSV #LINQ #XML.
We hope this information is useful to you, thank you very much for following this article.
Text version of the video
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
Slides
LINQ to SQL Tutorial – All Text Articles & Slides
LINQ to XML Tutorial Playlist
Dot Net, SQL, Angular, JavaScript, jQuery and Bootstrap complete courses
In your application there may be a need to transform an XML document into
1. CSV format
2. HTML format
3. Different XML format
In this video, we will discuss transforming the following XML document into CSV format.
[?xml version=”1.0″ encoding=”utf-8″?]
[Students]
[Student Country=”USA”]
[Name]Mark[/Name]
[Gender]Male[/Gender]
[TotalMarks]800[/TotalMarks]
[/Student]
[Student Country=”USA”]
[Name]Rosy[/Name]
[Gender]Female[/Gender]
[TotalMarks]900[/TotalMarks]
[/Student]
[Student Country=”India”]
[Name]Pam[/Name]
[Gender]Female[/Gender]
[TotalMarks]850[/TotalMarks]
[/Student]
[Student Country=”India”]
[Name]John[/Name]
[Gender]Male[/Gender]
[TotalMarks]950[/TotalMarks]
[/Student]
[/Students]
After transformation, data in the CSV file should look as shown below.
USA,Mark,Male,800
USA,Rosy,Female,900
India,Pam,Female,850
India,John,Male,950
Code to transform XML to CSV
StringBuilder sb = new StringBuilder();
string delimiter = “,”;
XDocument.Load(@”C:DemoDemoData.xml”).Descendants(“Student”)
.ToList().ForEach(element =]sb.Append(
element.Attribute(“Country”).Value + delimiter +
element.Element(“Name”).Value + delimiter +
element.Element(“Gender”).Value + delimiter +
element.Element(“TotalMarks”).Value + “rn”));
StreamWriter file = new StreamWriter(@”C:DemoDemoResult.csv”);
file.WriteLine(sb.ToString());
file.Close(); ..