Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with dash symbol in powershell

Tags:

powershell

I want to use dash symbol in xml node name but when i try to get that node it says something about unexpected token.

<hudson.scm.SubversionSCM_-ModuleLocation>
<remote>svn://svn.something.ru/testlib/trunk/SOAPUI/pmplatform/email</remote> 
</hudson.scm.SubversionSCM_-ModuleLocation>

$xmlone = New-Object XML
$xmlone.Load($scriptRoot+"\config.xml")
$xmlone.project.scm.locations.hudson.scm.SubversionSCM_-ModuleLocation
like image 346
Varyanica Avatar asked Jul 06 '10 14:07

Varyanica


People also ask

How do you type an em dash in PowerShell?

FYI, "–" is U+2013 En Dash while U+2014 Em Dash is "—"… In any case, '\u2013\u2014'. encode('utf-8').

What is dash in PowerShell?

dashes are switches\parameters\operators. The one you're referring to just happens a string operator, so any string passed with the -f will use it. https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_parameters?


1 Answers

Try quoting the name that has dashes in it:

PS > $xml = [xml]'<root><dash-it-all>text</dash-it-all></root>'
PS > $xml.root.'dash-it-all'
like image 130
OldFart Avatar answered Dec 25 '22 14:12

OldFart