1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

UiPathのXamlファイルに特定のコメントや表示名のアクティビティがあるか調べる

Posted at

PowerShellで万全

$TargetXaml = "C:\work\sample\Main.xaml" # 検索するXamlファイル

$Xaml = [Xml](("<?xml version=""1.0"" encoding=""utf-8"" ?>`n") + (Get-Content -Encoding UTF8 $TargetXaml))
$XmlNsMgr = New-Object -TypeName System.Xml.XmlNamespaceManager -ArgumentList $Xaml.NameTable

$XmlNsMgr.AddNamespace("sap2010", "http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation")

$ConditionXPath = [String] "//*[contains(@DisplayName , 'はが')]" # アクティビティ表示名に「はが」を含むアクティビティがあるか
# $ConditionXPath = [String] "//*[contains(@sap2010:Annotation.AnnotationText , 'ほげ')]" # 注釈に「ほげ」を含むアクティビティがあるか


if($Xaml.DocumentElement.SelectNodes($ConditionXPath, $XmlNsMgr).Count -gt 0)
{
    Write-Output ("該当ありました: " + $TargetXaml)
}

実際にはファイル一覧をGet-ChildItemあたりでごっそり持ってきて順次処理するような使い方になると思います!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?