Exist the possibility to concatenate more .xml files in just one .xml document using powershell? For example I have 14 .xml file which have the same format (columns/name of columns) and I want in concatenate all these .xml files in one bigger .xml file which will be imported in power bi template in order to create a general report?
1 Answer
I tried to use the PS code from example but it doesn't work for me:
$finalXml = "C:xmlfiles" foreach ($file in $files) { [xml]$xml = Get-Content $file
$finalXml += $xml.InnerXml } $finalXml += $xml.root.InnerXml ([xml]$finalXml).Save("$pwd\final.xml")
I get this error : Cannot convert value "C:xmlfiles" 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 line:7 char:1
- ([xml]$finalXml).Save("$pwd\final.xml")
-
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException + FullyQualifiedErrorId : InvalidCastToXmlDocument