powershell中的破折号问题 [英] Problem with dash symbol in powershell
本文介绍了powershell中的破折号问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 xml 节点名称中使用破折号,但是当我尝试获取该节点时,它说一些关于意外令牌的信息.
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
推荐答案
尝试引用包含破折号的名称:
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'
这篇关于powershell中的破折号问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文