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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The code in your question seems to work for me. I just added
testinside my string to show I can access the value, but it should work without it, too.Full Image
Casting a string also worked for me:
Full Image
…and I ran it with your string and it worked fine…

Full Image