problem with .Net xml importnode in powershell
Posted
by Trondh
on Server Fault
See other posts from Server Fault
or by Trondh
Published on 2009-08-05T08:12:54Z
Indexed on
2010/03/12
10:07 UTC
Read the original article
Hit count: 430
Hi, Im trying to construct a powershell script that uses some XML. I have a XML document where I try to add some values with email addresses. The finished xml document should have this format: (I'm only showing the relevant part of the xml here)
<emailAddresses>
<value>[email protected]</value>
<value>[email protected]</value>
<value>[email protected]</value>
</emailAddresses>
SO, in powershell I try to do this as a test, which fails:
$newNumber = [xml] '<value>555-1215</value>'
$newNode = $Request2.ImportNode($newNumber.value, $true)
$emailnode.AppendChild($newNode)
After some reading, I have figured out that if I do this, it suceeds:
$newNumber = [xml] '<value name="flubber">555-1215</value>'
$newNode = $Request2.ImportNode($newNumber.value, $true)
$emailnode.AppendChild($newNode)
So, I am stuck. I'm starting to wonder if I should use another function instead of importnode when I have several keys with the same name but different values.
As you guys probably have figured out by now, i'm not an expert in xml. ANy help appreciated!
© Server Fault or respective owner