I have defined an XML string using
$str = "<a><b></b></a>"
Now I want to load it into a [xml] variable to be able to manipulate it's nodes etc. The row below results in an error...
$str = [xml]"<a><b></b></a>"
How do I do this?
I have defined an XML string using
$str = "<a><b></b></a>"
Now I want to load it into a [xml] variable to be able to manipulate it's nodes etc. The row below results in an error...
$str = [xml]"<a><b></b></a>"
How do I do this?
I found this article to be pretty good: http://www.pluralsight-training.net/community/blogs/dan/archive/2006/11/25/42506.aspx
And this one: http://powershell.com/cs/blogs/ebook/archive/2009/03/30/chapter-14-xml.aspx
For when XML needs to be handled in PowerShell
Your question seems to work for me. How about you post the error so we can see what is going on? I just added test
inside my string to show I can access the value, but it should work without it too.
ANOTHER EDIT:
Casting a string also worked for me, so how about you show us some work since I can't reproduce your issue Full Image
...and I ran it with your string and it worked fine... Full Image