Vishal Kaushik

Vishal Kaushik

  • NA
  • 3
  • 2.9k

XML to CSV parser with column names in C#

Jan 28 2020 2:27 PM
Please help me to parse my xml into csv with column names. I need c# code in order to achieve my task. Below is my xml content:
 
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">  
  3. <soap:Body>  
  4. <GetAccountsResponse xmlns="http://Weiland.Ba.retrieval/">  
  5. <GetAccountsResult>  
  6. <AccountRecords>3071</AccountRecords>  
  7. <Accounts>  
  8. <Account>  
  9. <AccountId>6</AccountId>  
  10. <AccountNumber>000091016138</AccountNumber>  
  11. <AccountTitle>3946231 Canada Inc.</AccountTitle>  
  12. <BankId>70</BankId>  
  13. <BankName>Royal Bank of Canada</BankName>  
  14. <BankRtn>ROYCCAT2</BankRtn>  
  15. <BranchId xsi:nil="true"/>  
  16. <CompanyId>86</CompanyId>  
  17. <CurrencyName>Canada, Dollar</CurrencyName>  
  18. <CostCenter>4603</CostCenter>  
  19. <ActiveDate>1900-01-01T00:00:00</ActiveDate>  
  20. </Account>  
  21. </Accounts>  
  22. <AsOfDate>2019-10-31 06:04:36.059 -04:00</AsOfDate>  
  23. <BankRecords>0</BankRecords>  
  24. <CompanyRecords>0</CompanyRecords>  
  25. <ReturnCode>0</ReturnCode>  
  26. <Version>1.03</Version>  
  27. </GetAccountsResult>  
  28. </GetAccountsResponse>  
  29. </soap:Body>  
  30. </soap:Envelope>  
I need the value of tags from AccountId to ActiveDate. I have tried looking on google but not able to get right code. Please help me so that I can generate a csv file from above xml content with column names in csv file.

Answers (2)