0

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.