Been wondering if it would be possible to make a simple script to check if multiple criteria are met and make necessary amendments to file.
Moving on to example of what I have and what I want to achieve.
I have an xml file with 4 lines - number, year, model and man.
If <man>
is Ford or Dodge, I want no amendments to be made. But if <man>
is anything other than that, then I want to check if <year>
or <model>
are "NA" and remove the line with "NA".
<?xml version="1.0" encoding="UTF-8"?>
<CarStuff>
<fileName>CarExpor201217.xml</fileName>
<numberCars>5</numberCars>
<ref>2017XY</ref>
<carExo id="CAR0001_01">
<dealVen id="CAR0001_02">
<name>John</name>
<surname>Smith</surname>
</dealVen>
<soldCar id="CAR0001_03">
<amount>1811.10</amount>
<lotNumber>1</lotNumber>
<year>NA</year> - Line must be removed
<model>NA</model> - Line must be removed
<man>Acura</man>
</soldCar>
</carExo>
<carExo id="CAR0002_01">
<dealVen id="CAR0002_02">
<name>John</name>
<surname>Smith</surname>
</dealVen>
<soldCar id="CAR0002_03">
<amount>1811.10</amount>
<lotNumber>1</lotNumber>
<year>NA</year> - Line must be kept
<model>NA</model> - Line must be kept
<man>Ford</man>
</soldCar>
</carExo>
<carExo id="CAR0003_01">
<dealVen id="CAR0003_02">
<name>John</name>
<surname>Smith</surname>
</dealVen>
<soldCar id="CAR0003_03">
<amount>1811.10</amount>
<lotNumber>1</lotNumber>
<year>1997</year> - Line must be kept
<model>NA</model> - Line must be removed
<man>Bugati</man>
</soldCar>
</carExo>
<carExo id="CAR0004_01">
<dealVen id="CAR0004_02">
<name>John</name>
<surname>Smith</surname>
</dealVen>
<soldCar id="CAR0004_03">
<amount>1811.10</amount>
<lotNumber>1</lotNumber>
<year>1997</year> - Line must be kept
<model>NA</model> - Line must be kept
<man>Dodge</man>
</soldCar>
</carExo>
<carExo id="CAR0005_01">
<dealVen id="CAR0005_02">
<name>John</name>
<surname>Smith</surname>
</dealVen>
<soldCar id="CAR0005_03">
<amount>1811.10</amount>
<lotNumber>2</lotNumber>
<year>NA</year> - Line must be kept
<model>Charger</model> - Line must be kept
<man>Dodge</man>
</soldCar>
</carExo>
<carExo id="CAR0005_01">
<dealVen id="CAR0005_02">
<name>John</name>
<surname>Smith</surname>
</dealVen>
<soldCar id="CAR0005_03">
<amount>1811.10</amount>
<lotNumber>3</lotNumber>
<year>NA</year> - Line must be removed
<model>Dot</model> - Line must be kept
<man>Datsun</man>
</soldCar>
</carExo>
</CarStuff>
Grateful for all the comments and ideas.