+ Reply to Thread
Results 1 to 6 of 6

Import of multiple XML files

  1. #1
    Registered User
    Join Date
    01-03-2012
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    29

    Import of multiple XML files

    Hello,
    I have a problem with an each day task:
    1. Download from a set ftp a file (self extracting .exe) with set name to a set folder on my hard drive.
    2. Extract the file to get a varying number (I estimate 10 - 1000 separate files) of .xml files. All the files have the same schema/mapping.
    3. Check the same "tag" in each file against a set table of values (under 100 different values) -> find the files with desired values.
    4. Present them in a usable format.

    I was advised that all the points can be automated in Excel.
    Doing 1 and 2 manually I can live with so I started with point 3.
    As I have no experience with VBA and only a superficial grasp of Excel and programming I got stuck.

    A. First of all I tried to use (Developer -> XML -> Import) to import all the files at once (Idea from built in help)
    It does not work. I get "XML file importing error" window which lists all the files with either:
    "Not able to find XML map corresponding to this data"
    or "No data was imported or only a part of data was imported" <- no data in a workbook

    I tried to pre-map (dragged the map from the source) the workbook. It works fine for one file only or for the first file of many.

    I left it at that.

    B. I used (Data -> External Data -> Other sources -> from xml data) to get the files into a workbook.
    I recorded a macro to find out that I need to use
    Please Login or Register  to view this content.
    I just have to feed the names of the files to the function in a loop.(?)

    C. I wrote some code to check what names the files from directory have and to put them in an Array
    Please Login or Register  to view this content.
    It fills the array with the name of the first file in the folder an infinite number of times.
    As the help for "Dir" suggests I tried running Dir("") to get to the next file but with no success.

    Please excuse the length of the post but I do not know if any of the above is a good idea.
    Moreover my Excel is in Polish so I can only hope that I translated correctly.

    I would greatly appreciate any hints, advises or solutions.

    I have posted the same on another forum, but it is there for over a week with no replies, so I think I am in clear to post here.

    Edit:
    Sample XML files. I was not able to attach them as .xml so I cheated a bit.
    266355_2011.xml.xls
    266357_2011.xml.xls
    266359_2011.xml.xls
    Last edited by Gzdnkh; 01-23-2012 at 02:58 AM. Reason: uploading files

  2. #2
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Import of multiple XML files

    This should get you started.
    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: Import of multiple XML files

    hi,

    I have some other way a bit similar to presented by Chippy
    Please Login or Register  to view this content.
    Best Regards
    MaczaQ
    ---------------------------------------------------------------------------------------------------------------------------
    If you are satisfied with the solution(s) provided, please mark your thread as Solved
    If you are pleased with my answer consider to rate it. To thank someone who has helped you, click on the star icon below their name.
    - This way you will add him some reputation points ... thanks in advance.

  4. #4
    Registered User
    Join Date
    01-03-2012
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: Import of multiple XML files

    Hello, thank you for the help but I am in need of some more.

    Running both the codes imports the first file and the first map and then I get a:

    Run-time error '-2147467259 (90004005)'
    "Błąd importu. Nie zaimportowano żadnych danych" which translates to "Import error. No data was imported" i guess.

    I have no idea what is wrong, but I tried this (Chippy's code as base as it is more understandable for me with bits from maczaq)...:
    Please Login or Register  to view this content.
    ...and it worked, all the files got imported.
    I just do not know if there are any "holes" in the code. Are there any?

  5. #5
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: Import of multiple XML files

    Hello Gzdnkh,

    Could you attach any source XML file. I could try to test it (wgraj pliki z danymi do testu ;-)

  6. #6
    Registered User
    Join Date
    01-03-2012
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: Import of multiple XML files

    Hello,
    Thank you for all the help, now I have something to work with.
    So far I have discovered that every answer leads to many questions

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1