Results 1 to 2 of 2

Thread: Convert multiple XML files in CSV automatically,headers problem with 1 entry xml file
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    May 2019
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Convert multiple XML files in CSV automatically,headers problem with 1 entry xml file

    Hello everybody! Like the title i need to do this task. I found this code on web that fits perfectly with my goal:

    Public Sub ConvertXmlToXlsx()

    Application.DisplayAlerts = False

    Dim objFSO As Object
    Dim objFolder As Object
    Dim objFile As Object

    xmlFolder = "C:\Users\xxx\xxx\xxx\xxx"
    convFolder = "C:\Users\xxx\xxx\xxx\xxx"


    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFolder = objFSO.GetFolder(xmlFolder)
    For Each objFile In objFolder.Files
    If UCase(Right(objFile.Name, Len(XML))) = UCase(XML) Then
    NewFileName = convFolder & objFile.Name & ".xlsx"

    Workbooks.OpenXML (objFolder & "" & objFile.Name), LoadOption:=xlXmlLoadImportToList
    ActiveWorkbook.SaveAs Filename:=NewFileName

    ActiveWorkbook.Close

    End If
    Next objFile

    End Sub





    It works without any issues as long as there are at least 2 entries in the XML file but there many xml with just one entry and this code doesn't create the right header attribute for each value:

    right case(what i need)[IMG][/IMG]


    wrong one[IMG]
    upload photo
    [/IMG]

    in this last case there's no header and i need all attributes to import these in my neo4j database.
    Is there a way to set that script to automatically recognise every attribute for 1 entry xml file? Thanks to everybody

  2. #2
    New Member
    Join Date
    May 2019
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: How can I convert multiple XML files in CSV automatically,headers problem with 1 entry xml file

    up

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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