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
FYI, "–" is U+2013 En Dash while U+2014 Em Dash is "—"… In any case, '\u2013\u2014'. encode('utf-8').
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?
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With