Powershell - .replace string in dynamically created variable.

BALITWPG
BALITWPG used Ask the Experts™
on
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
$xd.loadXml($Result)
$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()
  }
 }
Comment
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"?
 $item.selectsinglenode($propertyList[$element].name).get_innerXml()

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

Author

Commented:
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