Powershell - .replace string in dynamically created variable.

BALITWPG used Ask the Experts™
I'm using the following code to parse a single level xml document ($result - generated from a previous SQL query) and dynamically create variables based on the tag names and assigning the contents to that variable.  Next, I need to alter the variables, replacing '&lt;' and '&gt;' with '<' and '>'.  I'm  not sure how to go about accomplishing that.

$xd = new-object System.Xml.XmlDocument
$nodelist = $xd.selectnodes("/NewDataSet/Table")
# get a list of node items.
$PropertyList = $nodelist | Get-Member -MemberType Property
ForEach($item in $nodelist)
 For ($Element=0; $Element -le $propertyList.count-1; $element++)
  New-Variable -name $propertyList[$element].name -value $item.selectsinglenode($propertyList[$element].name).get_innerXml()
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Are you wanting to get them out of "-value"?

You could use "replace":
 $item.selectsinglenode($propertyList[$element].name).get_innerXml().replace("&lt", "<").replace("&gt", ">")


Perfect, thank you very much.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial