yantaq
yantaq

Reputation: 4048

Powershell variable expansion along with a single quote

In the expression below I would like $key variable to be expanded to
"//configuration[@navtitle='Some Report']"
How do I achieve that? know that $key value is derived from external file

$key = "Some Report"
Xml.SelectNodes("//configuration[@title=$key]")

Upvotes: 0

Views: 307

Answers (1)

zdan
zdan

Reputation: 29480

Single quotes won't be parsed within double quotes. You could put the single quotes in $key or the string:

$key = "'Some Report'"
"//configuration[@title=$key]"

Output:

//configuration[@title='Some Report']

OR

$key = "Some Report"
"//configuration[@title='$key']"

Upvotes: 3

Related Questions