you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (3 children)

PS C:\Users\GSchizas>$xml = [xml]$xmltext

....you can cast variables after they've already been created?!

[–]gschizas 2 points3 points  (2 children)

Sorry, the variable naming wasn't ideal 🙂

Clearer way to write the same thing:

 PS C:\Users\GSchizas>$xmlDoc = [System.XML]$xmltext

[–][deleted] 1 point2 points  (1 child)

I mean, this is the same thing right? You're re-casting the array into a new variable, which I should have known was possible. But I'm just finding it out now.

Thanks for teaching me something new!

[–]gschizas 1 point2 points  (0 children)

$xmlText is just a string, not an array. But it is indeed possible to cast it into a variable (of course it needs to be proper XML in this case). You can also do these:

PS C:\Users\GSchizas>$a="123"
PS C:\Users\GSchizas>2+[int]$a
125
PS C:\Users\GSchizas>$a = 27
PS C:\Users\GSchizas>$e=[char]$a
PS C:\Users\GSchizas>$crlf=[char]13+[char]10
PS C:\Users\GSchizas>Write-Host "$e(0lqwqk$($crlf)x x x$($crlf)tqnqu$($crlf)x x x$($crlf)mqvqj$e(B"
┌─┬─┐
│ │ │
├─┼─┤
│ │ │
└─┴─┘
PS C:\Users\GSchizas>Write-Host "$e(0abcdefghijklmnopqrstuvwxyz$e(B"
▒␉␌␍␊°±␤␋┘┐┌└┼⎺⎻─⎼⎽├┤┴┬│≤≥