Solved

Import XML file into Excel

Posted on 2010-11-15
10
389 Views
Last Modified: 2012-05-10
Attached is a XML file and an Excel spreadsheet after I have imported this XML into it. Is it possible to rearrange the resulting spreadsheet so that the columns are Session#, SourceHost, SourcePath, StartTime, etc with the corressponding values listed by session #? Can this be done via the XML import process into Excel Or is VBA code necessary? Either way I would appreciate assistance. The current format is not manageable. Thanks.
BackUpJob1349.xml
Book3.xlsx
0
Comment
Question by:StampIT
  • 4
  • 4
  • 2
10 Comments
 
LVL 13

Expert Comment

by:gbanik
ID: 34137228
Use an XML parser to parse through the XML file and populate the Excel file. There may not be a straight forward way of achieving this. Use the Microsoft XML Library to do so.

Add it as reference in your project
http://msdn.microsoft.com/en-us/library/ms763701(VS.85).aspx

Check this to parse your data
http://msdn.microsoft.com/en-us/library/aa163921(office.10).aspx
0
 
LVL 7

Expert Comment

by:Bruce Cadiz
ID: 34138321
StampIT,

Here's a different approach by replacing your XML tags with HTML then opening in Excel.
Note: It will open the XML file and replace listed text string / tags with HTML tags then open in Excel. Seemed like the simplest approach since your XML was similarly structured to an HTML table.

Bruce ee-Q26615394.xls
0
 

Author Comment

by:StampIT
ID: 34140700
Thanks for the replies. Both of these are way over my head. I thought there might be a simpler way of performing this task.
Bruce: I ran your code with the file I had but it resulted in data in the first row in a language I did not understand. I probably did something wrong.
If I can I should probably withdraw the question.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 13

Expert Comment

by:gbanik
ID: 34140776
StampIT as I mentioned in my comment, there might not be a simpler way. But actually less difficult than u are thinking. This method is a tried and tested way and u can definitely give it a try.
I am confident about the direction.
0
 
LVL 7

Expert Comment

by:Bruce Cadiz
ID: 34140881
StampIT,

Here is your sample XML file and I've modified the Excel file to save the output in the same directory. It should do exactly what you have asked.

Save them to a folder that you have read/write access to. Then open the Excel file and hit the button to Select the XML File. You are running Windows aren't you? What version of Excel do you have?

Bruce ee-Example.zip
0
 

Author Comment

by:StampIT
ID: 34140958
Bruce,
      I am running Windows Vista and Excel 2007. Thanks
0
 
LVL 7

Accepted Solution

by:
Bruce Cadiz earned 500 total points
ID: 34141334
StampIT,

Then it should work, (I'm running XP and Office 2003 SP3). The funny character output is a question mark in a weird character set on the first line (probably and XML creation error) but essentially it's what is in attached (HTML file). I've also included .jpg's of the output in Excel and the Error message for the weird character.

Bruce ee-files.zip
0
 

Author Closing Comment

by:StampIT
ID: 34146330
Works exactly how I want it to.
0
 
LVL 7

Expert Comment

by:Bruce Cadiz
ID: 34146646
StampIT,

Thanks. I believe the suggestions by gbanik regarding the XML parser is something you should look at. While as he stated it may seem complicated, if you were to eventually incorporate it, you would have more functionality / flexibility in the long run, especially if your XML data structures change in the future.

Bruce
0
 

Author Comment

by:StampIT
ID: 34146807
Bruce,
      Thanks. I will keep that in mind.
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

773 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