Share via

Specified node is the wrong type" error after converting files to xml

2024-01-03T11:34:19.6333333+00:00
Hello, 

When transferring files, they import with the file extension "FILE". I ran ren *.* *.xml to convert them to xml document to use in my script. I receive this error when I run the script. Is there an additional property that I need to change in order for it to be recognized as the proper node type.

Select-Xml : The file '\\[FILE PATH].xml' cannot be read: The specified node cannot be inserted as 

the valid child of this node, because the specified node is the wrong type. 

At C:\[FILE PATH].ps1:35 char:10 

+     $ip = $(Select-Xml -Path $File_Path -XPath "//address[@addrtype=' ... 

+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

    + CategoryInfo          : InvalidArgument: (\\[FILE PATH].xml:String) [Select-Xml], ArgumentExcept 

   ion 

    + FullyQualifiedErrorId : ProcessingFile,Microsoft.PowerShell.Commands.SelectXmlCommand 

 

Select-Xml : The file '\\[FILE PATH].xml' cannot be read: The specified node cannot be inserted as 

the valid child of this node, because the specified node is the wrong type. 

At C:\[FILE PATH].ps1:36 char:11 

+ ...    $mac = $(Select-Xml -Path $File_Path -XPath "//address[@addrtype=' ... 

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

    + CategoryInfo          : InvalidArgument: (\\GRYFSW301\Dat...2_NMAP_Scan.xml:String) [Select-Xml], ArgumentExcept 

   ion 

    + FullyQualifiedErrorId : ProcessingFile,Microsoft.PowerShell.Commands.SelectXmlCommand
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

1 answer

Sort by: Most helpful
  1. Olaf Helper 47,621 Reputation points
    2024-01-03T12:00:59.9966667+00:00

    I ran ren . *.xml to convert them to xml document to use in my script.

    What's the source file content and how have you converted it to XML?

    Just changing the file extension to XML won't change anything on the file content.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.