awk script xml file remove nodes

I have an XML file that i need to post process and need to remove certain lines/nodes in the file in this example i want t remove all nodes that have the word 'confirmation' in the node name,

Example XML and what i have tried below.

I open the file and readin the contens then output
Source XML File

<ShipNoticeItem lineNumber="20" quantity="8">
 <ConfirmationStatus type="reject" quantity="0">
 <UnitOfMeasure>PACK</UnitOfMeasure>
 </ConfirmationStatus>
</ShipNoticeItem>
<ConfirmationItem lineNumber="30" quantity="0">
 <ConfirmationStatus type="reject" quantity="0">
 <UnitOfMeasure>PACK</UnitOfMeasure>
 </ConfirmationStatus>
</ConfirmationItem>

cat $MyFile | awk -F "<" 'BEGIN {
  TRUE=1;
  FALSE=0;
 }

	{
	if ( length($0)==0 )
	continue;
		
         if ( substr($2,1,4) !="Conf") 
	  {
	  print $0;
	  continue;	
	}	
			
						
	if ( substr($2,2,4) !="Conf")
	{
	print $0;
	continue;
	}

 }' > /tmp/outputfile.xml

Open in new window

IanPaskinAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

woolmilkporcCommented:
awk -F "<" 'BEGIN {
  TRUE=1;
  FALSE=0;
 }
        {
        if ( length($0)==0 )
        continue;
               
         if ( substr($2,1,4)=="Conf")
          {
         continue;    
          }      
                       
                                               
        if ( substr($2,2,4)=="Conf")
         {
        continue;
        }
         {
         print;
        }
 }' $MyFile  > /tmp/outputfile.xml

wmp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IanPaskinAuthor Commented:
Perfect thanks, works a treat.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.