Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

Export XML data from text file to Excel file

Question posted by: pulavarthipraveen (Newbie) on June 11th, 2008 02:50 PM
Overview: We have a requirement in the c#.NET 1.0 windows application. There will be some input text file[with extension .log] in the user’s machine[in C:\ or D:\ drive]. The user should browse and select the input text file and also select the destination path. click some “Convert” button, then the XML data which is present in the text file should be exported to a new excel sheet and this excel should be stored in the destination path which the user already selected.

Problem 1: The input text file contains normal text along with the repeated set of XML nodes for different data. We have to pick the specific XML nodes and their data and import into the excel sheet. As being the text file, how we can separate XML content from it. What can be the approach we can adopt?

Problem 2: a) Even we copy paste the “<MerchantReference>” value e.g 0000101151, to the excel sheet cell it’s being taken as 101151
b) Even we copy paste the “<CurrentTime>” value e.g. 06/03/2008 05:43:49.849 AM, to the excel sheet cell it’s being taken as 6/3/2008 5:43:50 AM

For Problem 2 we tried with “format cells” – Custom option of the excel sheet, but didn’t find the required one.

Please find below sample XML input which the (a)text file contains and the expected output[without formatting of MerchantReference and CurrentTime] which the excel sheet sholud contain(b).

We want to shown the XML nodes as heading/column and their data as different rows.

a)_ _ _ _ _
5:43:49 AM: Source:CPM_PaymentService.PaymentGateway.Auth, Message:
<TimeNode>
<AccountNumber>4290058061755517</AccountNumber>
<MerchantReference>0000101151</MerchantReference>
<Action>AUTH START</Action>
<CurrentTime>06/03/2008 05:43:49.849 AM</CurrentTime>
</TimeNode>
_ _ _ _ _ _

b)
AccountNumber MerchantReference Action CurrentTime
4290058061755517 101151 AUTH START 6/3/2008 5:43:50 AM


Please provide any possible solution which you come across. Thanks in advance.
Dököll's Avatar
Dököll
Moderator
1,923 Posts
June 27th, 2008
02:03 AM
#2

Re: Export XML data from text file to Excel file
Hey there!

See if this can give you an idea, it's in VB6 but get a a look, I think it helps address some of the issues:

http://bytes.com/forum/thread777267.html

Also, please look at related links, hope you can use some of the ideas there...

Later!

Reply
jkmyoung's Avatar
jkmyoung
Moderator
805 Posts
June 27th, 2008
02:28 PM
#3

Re: Export XML data from text file to Excel file
Problem 2:

It is format cells. Use the following 'custom' formats:
1. 0000000000
2. dd/mm/yyyy hh:mm:ss.000 AM/PM

Reply
Reply
Not the answer you were looking for? Post your question . . .
190,474 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top XML Forum Contributors