Node.AppendChild
(1)
XPath
(1)
Firstlevel01
(1)
Firstlevel02
(1)
Item03
(1)
Myxml
(1)
XML
(1)
Exp
(1)

Help adding XML element at specified "path"

Asked By Adrian
01-Feb-10 04:38 AM
Say I have the following XML in a variable called "$myxml"...


...How do I add (an set the value of) an element at, say,

Many Thanks,
=Adrian=

Try this:$xml =3D [xml]@"<root><firstlevel01><item01>First level 01 -

stej replied to Adrian
02-Feb-10 02:26 PM
Try this:

$xml =3D [xml]@"
$i =3D $xml.CreateElement('item03')
$i.InnerText =3D 'this is test'
$node =3D Select-Xml -Xml $xml -XPath /root/firstlevel02 | select -exp
Node
$node.AppendChild($i) > $null

$xml | Format-Custom
$xml.root.firstlevel02
Post Question To EggHeadCafe