I have tried multiple ways to insure I have a true XML object but I get this error:
Get-XmlNodes : Cannot process argument transformation on parameter 'XmlDocument'. Cannot
convert value "System.Object[]" to type "System.Xml.XmlDocument". Error: "The specified node
cannot be inserted as the valid child of this node, because the specified node is the wrong
type."
At C:\Users\OrderFile.ps1:155 char:19
+ ... Get-XmlNodes($XmlDocument, $ElementPath, $FullNPID, $NodeSeparatorCha ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: ) [Get-XmlNodes], ParameterBindingArgumentTransfor
mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-XmlNodes
Here are some of the ways I tried to overcome the issue, but none of them solve my issue.
Creating the Xml object:
Call function:
Function Parameters:
If anyone has any idea why I am getting this error please let me know.
Get-XmlNodes : Cannot process argument transformation on parameter 'XmlDocument'. Cannot
convert value "System.Object[]" to type "System.Xml.XmlDocument". Error: "The specified node
cannot be inserted as the valid child of this node, because the specified node is the wrong
type."
At C:\Users\OrderFile.ps1:155 char:19
+ ... Get-XmlNodes($XmlDocument, $ElementPath, $FullNPID, $NodeSeparatorCha ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: ) [Get-XmlNodes], ParameterBindingArgumentTransfor
mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-XmlNodes
Here are some of the ways I tried to overcome the issue, but none of them solve my issue.
Creating the Xml object:
Code:
[xml]$XmlDocument = [xml](Get-Content -Path C:\Users\xml.xml -Raw)
[System.Xml.XmlDocument]$XmlDocument = [System.Xml.XmlDocument](Get-Content -Path C:\Users\xml.xml)
Code:
$XmlDocument = [xml](Get-Content -Path C:\Users\xml.xml -Raw)
$XmlDocument = [System.Xml.XmlDocument](Get-Content -Path C:\Users\xml.xml)
Code:
$XmlDocument = Get-Content -Path "C:\Users\xml.xml"
$XmlDocument = [xml]($Content -join "")
Code:
$ReferenceXML = [xml]''
$ReferenceXML.Load($("C:\Users\xml.xml"))
Code:
$trueXml = Get-XmlNodes([REF]($XmlDocument,[string] $ElementPath,[string] $FullNPID,[string] $NodeSeparatorCharacter)
$trueXml = Get-XmlNodes([xml]($XmlDocument,[string] $ElementPath,[string] $FullNPID,[string] $NodeSeparatorCharacter)
$trueXml = Get-XmlNodes([System.Xml.XmlDocument]$XmlDocument,[string] $ElementPath,[string] $FullNPID,[string] $NodeSeparatorCharacter)
$trueXml = Get-XmlNodes($XmlDocument, $ElementPath, $FullNPID, $NodeSeparatorCharacter)
Code:
function Get-XmlNodes([ xml ]$XmlDocument, [string]$NodePath, [string]$NamespaceURI = "", [string]$NodeSeparatorCharacter = '.'){...}
function Get-XmlNodes([System.Xml.XmlDocument]$XmlDocument, [string]$NodePath, [string]$NamespaceURI = "", [string]$NodeSeparatorCharacter = '.'){...}
If anyone has any idea why I am getting this error please let me know.