Forked from jstangroome/Remove-WorkflowPresentation.ps1
Created
March 28, 2012 14:45
Revisions
-
tylerd revised this gist
Mar 28, 2012 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,6 +28,7 @@ $x = [xml](Get-Content -Path $Path) $nsmgr = New-XmlNamespaceManager -XmlDocument $x 'http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation', 'http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation', 'clr-namespace:System.Activities.Debugger;assembly=System.Activities' | ForEach-Object { $Namespace = $_ @@ -43,4 +44,4 @@ $nsmgr = New-XmlNamespaceManager -XmlDocument $x } } } $x.Save($Path + '.clean') -
jstangroome created this gist
Mar 21, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ #requires -version 2.0 [CmdletBinding()] param( [parameter(Mandatory=$true)] [ValidateScript({ $_ | Test-Path -PathType Leaf })] [string] $Path ) function New-XmlNamespaceManager ($XmlDocument, $DefaultNamespacePrefix) { $NsMgr = New-Object -TypeName System.Xml.XmlNamespaceManager -ArgumentList $XmlDocument.NameTable $DefaultNamespace = $XmlDocument.DocumentElement.GetAttribute('xmlns') if ($DefaultNamespace -and $DefaultNamespacePrefix) { $NsMgr.AddNamespace($DefaultNamespacePrefix, $DefaultNamespace) } $XmlDocument.DocumentElement.Attributes | Where-Object { $_.Prefix -eq 'xmlns' } | ForEach-Object { $NsMgr.AddNamespace($_.LocalName, $_.Value) } return ,$NsMgr # unary comma wraps $NsMgr so it isn't unrolled } $ErrorActionPreference = 'Stop' Set-StrictMode -Version Latest $x = [xml](Get-Content -Path $Path) $nsmgr = New-XmlNamespaceManager -XmlDocument $x 'http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation', 'clr-namespace:System.Activities.Debugger;assembly=System.Activities' | ForEach-Object { $Namespace = $_ $prefix = $nsmgr.LookupPrefix($namespace) if ($prefix) { $x.SelectNodes("//$($prefix):*", $nsmgr) | ForEach-Object { $_.ParentNode.RemoveChild($_) | Out-Null } $x.SelectNodes("//@*[namespace-uri()='$namespace']") | ForEach-Object { $_.OwnerElement.RemoveAttributeNode($_) | Out-Null } } } $x.Save($Path + '.clean')