function Get-IniContent ($filePath) { $ini = @{} switch -regex -file $FilePath { “^\[(.+)\]” # Section { $section = $matches[1] $ini[$section] = @{} $CommentCount = 0 } “^(;.*)$” # Comment { $value = $matches[1] $CommentCount = $CommentCount + 1 $name = “Comment” + $CommentCount $ini[$section][$name] = $value } “(.+?)\s*=(.*)” # Key { $name,$value = $matches[1..2] $ini[$section][$name] = $value } } return $ini } foreach ($arg in $args) { Write-Host "Arg: $arg"; $Filename = $arg $Nameonly = (Get-Item $Filename).DirectoryName+"\"+(Get-Item $Filename).Basename $myIni = Get-IniContent($Filename) $myIni["0"] # Set the File Name $filePath = $Nameonly+".XML" Write-Host "Output : " $filepath # Create The Document $XmlWriter = New-Object System.XMl.XmlTextWriter($filePath,$Null) # Set The Formatting $xmlWriter.Formatting = "Indented" $xmlWriter.Indentation = "4" # Write the XML Decleration $xmlWriter.WriteStartDocument() # Set the XSL $XSLPropText = "type='text/xsl' href='style.xsl'" $xmlWriter.WriteProcessingInstruction("xml-stylesheet", $XSLPropText) # Write Root Element $xmlWriter.WriteStartElement("recording") # Write the Document #$xmlWriter.WriteStartElement("Servers") $xmlWriter.WriteElementString("title",$myIni["0"]["Title"]) if ($myIni["0"]["Info"].Equals("")) { $shortdesc= $myIni["0"]["Description"] $shortdesc= $shortdesc.Substring(0, $shortdesc.IndexOf(" ", 80)) $xmlWriter.WriteElementString("subtitle",$shortdesc) } else { $xmlWriter.WriteElementString("subTitle",$myIni["0"]["Info"]) } $xmlWriter.WriteElementString("description",$myIni["0"]["Description"]) $xmlWriter.WriteElementString("channel",$myIni["Media"]["Channel"]) $xmlWriter.WriteElementString("network",$myIni["Media"]["Channel"]) # Write Close Tag for Root Element $xmlWriter.WriteEndElement # <-- Closing RootElement # End the XML Document $xmlWriter.WriteEndDocument() # Finish The Document $xmlWriter.Finalize $xmlWriter.Flush $xmlWriter.Close() } # foreach arg