Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

Below is the xml i am having in a .xml file

HTML
<pre><?xml version="1.0" encoding="UTF-8"?>
<data>
  <input>
    <common>
      <AOGatewayID></AOGatewayID>
      <SRNUM></SRNUM>
      <WONUM></WONUM>
      <INCNUM />
      <ResolverGroup></ResolverGroup>
      <ContactEmail></ContactEmail>
    </common>
    <params>:11/30/2016;:;:;:;:;:;:;:;:;:;:;:;:;:;:;:;:;:;:;:;:;:;:;:;:;RequestedFor:NEX9KUT</params>
  </input>
  <Processname></Processname>
  <retry-count></retry-count>
  <status></status>
  <Error_Desc></Error_Desc>
</data>




I need to delete the <params> tag and save the new xml in separate file

Please help me on this.

What I have tried:

[Xml]$xml = Get-Content "D:\Logs\File.xml"

$parent_xpath = '/data/input'
$nodes = $xml.SelectNodes($parent_xpath)
$nodes | % {
$child_node = $_.SelectSingleNode('params')
$_.RemoveChild($child_node) | Out-Null
}
Posted
Comments
Richard MacCutchan 17-Aug-16 6:34am    
And what happened when you tried it?
Black_Rose 17-Aug-16 12:02pm    
it's not affecting anything to the xml string.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900