none
invalid procedure call or argument --while loading xml file RRS feed

  • Question

  • Getting the error while loading xml file

    1. have taken all file names in a specific folder

    2. Trying to load the file when the extn is .xml  --here i'm getting error

    3. Then i have to update the xml nodes

    inbound_path = "myfilefullpath"
        
        'Set oFSO = CreateObject("Scripting.FileSystemObject")
        Set oFolder = oFSO.GetFolder(inbound_path)
        
        MsgBox oFolder
      
            
        Set oFileCollection = oFolder.Files
        
        For Each oTempFile In oFileCollection
        
            If oTempFile Like "*.xml" Then
            
                MsgBox oTempFile
                        
                Set xmlDoc = CreateObject("Microsoft.XMLDOM")
                xmlDoc.Async = "False"
                File_Found = xmlDoc.Load(oTempFile)    'Getting error here saying invalid procedure call or arguemnt
                
                If File_Found = False Then
                    MsgBox ("The specified inbound File is not found")
                Else

                   'Do stuff like updating xml

                Endif

           Endif

        Next


    • Edited by Raj Kunnuru Thursday, April 5, 2018 6:38 AM
    Thursday, April 5, 2018 6:37 AM

Answers

  • When you post in a technical forum you need to post code using the code posting tool provided on the edit bar.

    inbound_path = "d:\scripts"
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set xmlDoc = CreateObject("Microsoft.XMLDOM")
    xmlDoc.Async = False
    
    Set oFolder = oFSO.GetFolder(inbound_path)
    For Each file In oFolder.Files
         If file.Type = "XML Document" Then
             WScript.Echo file.Name
             xmlDoc.Load(file.Name)
             ' process xmlDoc
        End If
    Next
    
    	

    Since you do not have any scripting knowledge I recommend learning with PowerShell.  VBScript is obsolete.

    Here is the same code in PowerShell:

    Get-ChildItem d:\scripts\*.xml | 
         ForEach-Object{
              Write-Host $_ 
              [xml]$xmlDoc = Get-Content $_
              # process $xmlDoc
         }


    \_(ツ)_/



    Thursday, April 5, 2018 7:28 AM

All replies

  • When you post in a technical forum you need to post code using the code posting tool provided on the edit bar.

    inbound_path = "d:\scripts"
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set xmlDoc = CreateObject("Microsoft.XMLDOM")
    xmlDoc.Async = False
    
    Set oFolder = oFSO.GetFolder(inbound_path)
    For Each file In oFolder.Files
         If file.Type = "XML Document" Then
             WScript.Echo file.Name
             xmlDoc.Load(file.Name)
             ' process xmlDoc
        End If
    Next
    
    	

    Since you do not have any scripting knowledge I recommend learning with PowerShell.  VBScript is obsolete.

    Here is the same code in PowerShell:

    Get-ChildItem d:\scripts\*.xml | 
         ForEach-Object{
              Write-Host $_ 
              [xml]$xmlDoc = Get-Content $_
              # process $xmlDoc
         }


    \_(ツ)_/



    Thursday, April 5, 2018 7:28 AM
  • Yup, got it now.

    I may need to refresh my programming and scripting fundamentals. As a tester i was not involved in any coding part in the years. Meanwhile i am trying to create a macro for my project. Hence tried my query here.

    Thanks for your recommendation on PowerShell. I will learn it.

    Thursday, April 5, 2018 9:24 AM