开发者

Accessing complex properties like "system.serviceModel" when using Powershell to parse xml [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How can you use PowerShell's . (dot) notation to walk through elements with periods in the element name?

I know that powershell will add properties to XmlElements to simplify accessing the elements and attributes.

When parsing a web.config, you get elements like 'system.serviceModel".

When a pass the XmlElement to Get-member, I开发者_如何转开发 can see that this is a property, but when I try to access the property I get an error message.

I assume that it is because the engine is looking for a property called system who has a property called serviceModel and not a property called "system.serviceModel"

What would be the best way to parse and access these elements?


I don't have a web.config file to parse right now, but if I understand the problem it is that in the file there exists a node with the name system.servicemodel. To access a node like that you just quote it. So if you have a variable $xml that represented the parent of that node, you could access it via:

$xml.'system.servicemodel'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜