Reputation: 163
I have an xml which looks like this
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http:www.springframework.net">
<object id="id1" type="1" method="1">
<property name="name" ref="serv1"/>
</object>
<object id="id2" type="2" method="2">
<property name="name2" ref="serv2"/>
</object>
</objects>
Now when i do this in power shell
$xmlFile=get-content $filename
$xmlFile.selectNodes("/objects/object[@id='id1']")
it does not return anything (returns null)
I need to modify the property value for one of the objects. any help is welcome.Thanks
Upvotes: 0
Views: 58
Reputation: 36277
You just need to define that it is an XML object, so change the first line to:
[xml]$xmlfile = get-content $filename
That should solve your problem.
Upvotes: 1