Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

shell using Loops to Add Element in XML File in Powershell

$xmlFragment=$log.CreateDocumentFragment()
$clients = 'Sample1.com','Sample2.com'    
$targets = $log.selectnodes('//Data')

for ($i = 0; $i -lt $targets.Count; $i++) {
    $rows = $targets[$i].selectnodes(".//Row")
    $item = $clients[$i]
    $new_node = "<client>$item</client>"    
    foreach ($row in $rows) {
        $xmlFragment.InnerXML=$new_node
        $row.PrependChild($xmlFragment)
    }
}
 
PREVIOUS NEXT
Tagged: #shell #Loops #Add #Element #XML #File #Powershell
ADD COMMENT
Topic
Name
4+4 =