I have Problems to get a node via XPATH in the powershell

by Oct 7, 2011

Hello to all,

I thought its time to learn how to script a little bit with powershell. I wanted to start with realy simple problem. I want to change a xml node (MultiBlock.Block.EmbBlocks.Block.SymbolAttrs.SymbolAttr.AttrOrder) value according to an other node (MultiBlock.Block.EmbBlocks.Block.SymbolAttrs.SymbolAttr.ParamName) value. So easy so far.

In the link my test file.

community.idera.com/…/Example.xml

After solving the common problems to get the powershell somehow to run I started with my script.

    $xml = New-Object xml

    $xml = [xml] (get-content C:Example.xml)
    
    $xml.MultiBlock.Block.EmbBlocks.Block

Up to here its working "Smile", but this is not where I want to go.

If I replace the last line by this line I get no printout any more "Sad"

    $xml.MultiBlock.Block.EmbBlocks.Block.SymbolAttrs.SymbolAttr.ParamName

If I try it with the next line I should get the same printout as I got with the first line. But there is no printout coming. Why ?

    $xml.SelectNodes("/MultiBlock/Block/EmbBlocks/Block")

What am I doing wrong ?

Thanks for your answers