Python lxml - retrieved elements nodes aren't removed
<p>I have an xml doxument I want to remove any line of xml that contains</p>

<pre><code>number="0"
</code></pre>

<p>This is a sample</p>

<pre><code>  &lt;race id="219729" number="2" nomnumber="8" division="0" name="NEWGATE BREEDERS' PLATE" mediumname="BRDRS PLTE" shortname="BRDRS PLTE" stage="Acceptances" distance="1000" minweight="50" raisedweight="0" class="~         " age="2         " grade="0" weightcondition="SW        " trophy="0" owner="0" trainer="0" jockey="0" strapper="0" totalprize="150000" first="89100" second="29700" third="14850" fourth="7425" fifth="2970" time="2016-10-01T12:55:00" bonustype="          " nomsfee="0" acceptfee="0" trackcondition="          " timingmethod="          " fastesttime="          " sectionaltime="          " formavailable="0" racebookprize="Of $150000. First $89100, second $29700, third $14850, fourth $7425, fifth $2970, sixth $1485, seventh $1485, eighth $1485"&gt;
    &lt;condition line="1"&gt;Of $150000. First $89100, second $29700, third $14850, fourth $7425, fifth $2970, sixth $1485, seventh $1485, eighth $1485&lt;/condition&gt;
    &lt;condition line="3"&gt;No class restriction, Set Weights, For Two-Years-Old, Colts and Geldings, (Listed)&lt;/condition&gt;
    &lt;condition line="5"&gt;No Allowances for apprentices. Field Limit: 14 + 4 EM&lt;/condition&gt;
    &lt;nomination number="1" saddlecloth="1" horse="Bowerman" id="207678" idnumber="" regnumber="" blinkers="0" trainernumber="81525" trainersurname="Freedman" trainerfirstname="Michael" trainertrack="Randwick" rsbtrainername="Michael Freedman" jockeynumber="1472" jockeysurname="McEvoy" jockeyfirstname="Kerrin" barrier="3" weight="56" rating="0" description="B C 2 Snitzel x Sabanci (Encosta de Lago)" colours="Red, Yellow Stars And Halved Sleeves, Red And Yellow Star Cap" owners="China Horse Club Racing Pty Ltd (Mgr: A K Teo) Winstar Farm Llc (Mgr: J Mullikin)  " dob="2014-08-11T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator="" /&gt;
    &lt;nomination number="2" saddlecloth="2" horse="Condor Heroes" id="207750" idnumber="" regnumber="" blinkers="0" trainernumber="685" trainersurname="Ryan" trainerfirstname="Gerald" trainertrack="Rosehill" rsbtrainername="Gerald Ryan" jockeynumber="40275" jockeysurname="Clark" jockeyfirstname="Tim" barrier="10" weight="56" rating="0" description="B C 2 Not a Single Doubt x Gosetgo (More Than Ready(USA))" colours="Yellow, Red Sun Logo, Red Epaulettes, Hooped Sleeves, Red Cap With Gold Logo" owners="Sun Bloodstock Pty Ltd (Mgr:  Ms M C Cheng)" dob="2014-09-29T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator="" /&gt;
    &lt;nomination number="4" saddlecloth="4" horse="Invader" id="207745" idnumber="" regnumber="" blinkers="0" trainernumber="81215" trainersurname="" trainerfirstname="" trainertrack="Randwick" rsbtrainername="Peter &amp;amp; Paul Snowden" jockeynumber="331" jockeysurname="Brown" jockeyfirstname="Corey" barrier="9" weight="56" rating="0" description="CH C 2 Snitzel x Flame of Sydney (Encosta de Lago)" colours="Red, Yellow Stars And Halved Sleeves, Red And Yellow Star Cap" owners="Newgate S F (Mgr: G D Murphy), Aquis Farm (Mgr: Miss K A Fogden), China Horse Club Racing Pty Ltd (Mgr: A K Teo), Horse Ventures (Mgr: M B Sandblom) &amp;amp; Winstar Farm Llc (Mgr: J Mullikin)" dob="2014-10-01T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator="" /&gt;
    &lt;nomination number="5" saddlecloth="5" horse="Khan" id="207711" idnumber="" regnumber="" blinkers="0" trainernumber="81215" trainersurname="" trainerfirstname="" trainertrack="Randwick" rsbtrainername="Peter &amp;amp; Paul Snowden" jockeynumber="40133" jockeysurname="Shinn" jockeyfirstname="Blake" barrier="1" weight="56" rating="0" description="CH C 2 Exceed And Excel x Mandawara(FR) (Daylami(IRE))" colours="Dark Green, Gold Epaulettes" owners="James Harron Bloodstock Colts, Mrs B C Bateman, Love Racing, Doyles Breeding &amp;amp; Racing, P Mehrten, Rockingham Thoroughbreds, J A &amp;amp; Mrs F A Ingham, G1G Racing &amp;amp; Breeding &amp;amp; N Gillard" dob="2014-08-09T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator="" /&gt;
    &lt;nomination number="6" saddlecloth="6" horse="Medal Kun" id="207681" idnumber="" regnumber="" blinkers="0" trainernumber="81483" trainersurname="Cummings" trainerfirstname="James" trainertrack="Randwick" rsbtrainername="James Cummings" jockeynumber="336" jockeysurname="Boss" jockeyfirstname="Glen" barrier="7" weight="56" rating="0" description="BR C 2 Medaglia D'oro(USA) x Run for Roses (Danehill(USA))" colours="Red, Black Stripes" owners="Gooree Stud (Mgr: E M Cojuangco)" dob="2014-09-30T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator="" /&gt;
    &lt;nomination number="7" saddlecloth="7" horse="Misty Lad" id="207698" idnumber="" regnumber="" blinkers="1" trainernumber="81637" trainersurname="" trainerfirstname="" trainertrack="Randwick" rsbtrainername="Gai Waterhouse &amp;amp; Adrian Bott" jockeynumber="349" jockeysurname="Bowman" jockeyfirstname="Hugh" barrier="5" weight="56" rating="0" description="B C 2 Redoute's Choice x Anadan (Anabaa(USA))" colours="Gold, Purple Star, Gold And White Stars Sleeves, Purple Cap" owners="Mt Hallowell Stud (Mgr: C G Thompson) &amp;amp; D K M Walpole " dob="2014-10-09T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator="" /&gt;
    &lt;nomination number="8" saddlecloth="8" horse="Opulentus" id="207699" idnumber="" regnumber="" blinkers="1" trainernumber="81215" trainersurname="" trainerfirstname="" trainertrack="Randwick" rsbtrainername="Peter &amp;amp; Paul Snowden" jockeynumber="84015" jockeysurname="Avdulla" jockeyfirstname="Brenton" barrier="8" weight="56" rating="0" description="CH C 2 Choisir x Aurum Valley (Made of Gold(USA))" colours="Dark Green, Gold Epaulettes" owners="James Harron Bloodstock Colts, Mrs B C Bateman, Love Racing, Doyles Breeding &amp;amp; Racing, P Mehrten, Rockingham Thoroughbreds, J A &amp;amp; Mrs F A Ingham, G1G Racing &amp;amp; Breeding, S N Gillard, Archer Racing, Mrs C J Inglis, D Saab &amp;amp; Platinum Breeding &amp;amp; Racing" dob="2014-08-24T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator="" /&gt;
    &lt;nomination number="9" saddlecloth="9" horse="Piracy" id="207724" idnumber="" regnumber="" blinkers="0" trainernumber="235" trainersurname="O'Shea" trainerfirstname="John" trainertrack="Agnes Banks/Hawkesbury" rsbtrainername="John O'Shea" jockeynumber="86876" jockeysurname="McDonald" jockeyfirstname="James" barrier="12" weight="56" rating="0" description="B C 2 Exceed And Excel x Plagiarize (Stravinsky(USA))" colours="Royal Blue" owners="Godolphin" dob="2014-09-25T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator="" /&gt;
    &lt;nomination number="10" saddlecloth="10" horse="Prophet's Voice" id="207523" idnumber="" regnumber="" blinkers="0" trainernumber="7626" trainersurname="Sharah" trainerfirstname="John" trainertrack="Warwick Farm" rsbtrainername="John Sharah" jockeynumber="57544" jockeysurname="Hyeronimus" jockeyfirstname="Adam" barrier="2" weight="56" rating="0" description="B C 2 Poet's Voice(GB) x Gold Beauty (Street Cry(IRE))" colours="Black, White Hooped Sleeves And Cap" owners="J M Sharah " dob="2014-10-15T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator="" /&gt;
    &lt;nomination number="11" saddlecloth="11" horse="Showtime" id="207713" idnumber="" regnumber="" blinkers="0" trainernumber="77974" trainersurname="Hawkes" trainerfirstname="Michael" trainertrack="Rosehill" rsbtrainername="Michael, Wayne &amp;amp; John Hawkes" jockeynumber="51661" jockeysurname="Berry" jockeyfirstname="Tommy" barrier="14" weight="56" rating="0" description="CH C 2 Snitzel x Flidais (Timber Country(USA))" colours="Red, Yellow Stripes, Black Sleeves, Red And Yellow Striped Cap" owners="Arrowfield Pastoral Syndicate (Mgr: J M Messara), K Yoshida, Belford Productions Syndicate (Mgr: A B Jones), Pinecliff Racing Syndicate (Mgr: J B Munz), Koundouris Bloodstock Syndicate (Mgr: A E Koundouris), J G Moore &amp;amp; G P I Racing Syndicate (Mgr: G P Ingham)" dob="2014-09-21T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator="" /&gt;
    &lt;nomination number="12" saddlecloth="12" horse="Spencer" id="207700" idnumber="" regnumber="" blinkers="1" trainernumber="38701" trainersurname="Cummings" trainerfirstname="Anthony" trainertrack="Randwick" rsbtrainername="Anthony Cummings" jockeynumber="57688" jockeysurname="Schofield" jockeyfirstname="Glyn" barrier="6" weight="56" rating="0" description="B C 2 Pierro x Alice's Smart(USA) (Smart Strike(CAN))" colours="Yellow, Red Quarters, Red and White Checked Armbands And Checked Cap" owners="Edinburgh Park (I Smith), S Bennett, C Battese, S K Bennett, P R A Falk, M J Hayne  B A Rutter, Glenrock (H Cooper) &amp;amp; Monaro Bloodstock (R J Logan)" dob="2014-09-28T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator="" /&gt;
    &lt;nomination number="13" saddlecloth="13" horse="The Mission" id="207726" idnumber="" regnumber="" blinkers="0" trainernumber="318" trainersurname="Perry" trainerfirstname="Paul" trainertrack="Newcastle" rsbtrainername="Paul Perry" jockeynumber="48503" jockeysurname="Williams" jockeyfirstname="Craig" barrier="4" weight="56" rating="0" description="B C 2 Choisir x My Amelia (Redoute's Choice)" colours="Yellow, Black Sash, Armbands And Cap" owners="Ms C G Collis, Mrs B J Grant, Mrs J P Poole &amp;amp; Mrs D M McCarthy" dob="2014-09-07T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator="" /&gt;
    &lt;nomination number="14" saddlecloth="14" horse="Thy Kingdom Come" id="207685" idnumber="" regnumber="" blinkers="0" trainernumber="77972" trainersurname="Thompson" trainerfirstname="John P" trainertrack="Randwick" rsbtrainername="John P Thompson" jockeynumber="46930" jockeysurname="Angland" jockeyfirstname="Tye" barrier="11" weight="56" rating="0" description="CH C 2 Lope de Vega(IRE) x Family Jewels (Secret Savings(USA))" colours="Royal Blue And Gold Diagonal Stripes, White Cap And Pom Pom" owners="Francis Racing (Mgr: J Francis), Dr K P Rewell, G Bakhos, M J Grace, T Khoury &amp;amp; B D Lawrence " dob="2014-08-01T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator="" /&gt;
    &lt;nomination number="0" saddlecloth="0" horse="Inquiry" id="207696" idnumber="" blinkers="0" trainernumber="0" jockeynumber="0" barrier="13" weight="0" rating="0" description="CH C 2 Exceed And Excel x Screen (Lonhro)" colours="Royal Blue" dob="2014-09-19T00:00:00" age="2" career="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="0" decimalmargin="0.00" penalty="0" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator="" /&gt;
  &lt;/race&gt;
</code></pre>

<p>I am able to return the elements</p>

<pre><code>from lxml import etree
import csv

with open("20161001RAND0.xml", 'rb') as f, open(
        "output/310916RABD.csv", 'w', newline='') as csvf:
    tree = etree.parse(f)
    root = tree.getroot()
    for nom in root.iter("nomination"):
        if nom.attrib['number'] == '0':
            nom.getparent().remove(nom)
            print(nom)
</code></pre>

<p>The output shows I got the element</p>

<pre><code>Â± |master U:1 ?:1 â| â python3 race.py 
&lt;Element nomination at 0x7f3e1f7c8f88&gt;
</code></pre>

<p>However the item still remains, how can I delete the line so that it would return with this line removed</p>

<pre><code> &lt;nomination number="0" saddlecloth="0" horse="Inquiry" id="207696" idnumber="" blinkers="0" trainernumber="0" jockeynumber="0" barrier="13" weight="0" rating="0" description="CH C 2 Exceed And Excel x Screen (Lonhro)" colours="Royal Blue" dob="2014-09-19T00:00:00" age="2" career="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="0" decimalmargin="0.00" penalty="0" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator="" /&gt;
</code></pre>

<p>I cannot reproduce it, here is the processing code completely based on yours:</p>

<pre><code>from lxml import etree

with open("input.xml", 'rb') as input_file, open("output.xml", 'wb') as output_file:
    tree = etree.parse(input_file)
    root = tree.getroot()
    for nom in root.iter("nomination"):
        if nom.attrib['number'] == '0':
            nom.getparent().remove(nom)
            print(nom)

    tree.write(output_file)
</code></pre>

<p>The content of the <code>output.xml</code> after running this code:</p>

<pre><code>&lt;race id="219729" number="2" nomnumber="8" division="0" name="NEWGATE BREEDERS' PLATE" mediumname="BRDRS PLTE" shortname="BRDRS PLTE" stage="Acceptances" distance="1000" minweight="50" raisedweight="0" class="~         " age="2         " grade="0" weightcondition="SW        " trophy="0" owner="0" trainer="0" jockey="0" strapper="0" totalprize="150000" first="89100" second="29700" third="14850" fourth="7425" fifth="2970" time="2016-10-01T12:55:00" bonustype="          " nomsfee="0" acceptfee="0" trackcondition="          " timingmethod="          " fastesttime="          " sectionaltime="          " formavailable="0" racebookprize="Of $150000. First $89100, second $29700, third $14850, fourth $7425, fifth $2970, sixth $1485, seventh $1485, eighth $1485"&gt;
    &lt;condition line="1"&gt;Of $150000. First $89100, second $29700, third $14850, fourth $7425, fifth $2970, sixth $1485, seventh $1485, eighth $1485&lt;/condition&gt;
    &lt;condition line="3"&gt;No class restriction, Set Weights, For Two-Years-Old, Colts and Geldings, (Listed)&lt;/condition&gt;
    &lt;condition line="5"&gt;No Allowances for apprentices. Field Limit: 14 + 4 EM&lt;/condition&gt;
    &lt;nomination number="1" saddlecloth="1" horse="Bowerman" id="207678" idnumber="" regnumber="" blinkers="0" trainernumber="81525" trainersurname="Freedman" trainerfirstname="Michael" trainertrack="Randwick" rsbtrainername="Michael Freedman" jockeynumber="1472" jockeysurname="McEvoy" jockeyfirstname="Kerrin" barrier="3" weight="56" rating="0" description="B C 2 Snitzel x Sabanci (Encosta de Lago)" colours="Red, Yellow Stars And Halved Sleeves, Red And Yellow Star Cap" owners="China Horse Club Racing Pty Ltd (Mgr: A K Teo) Winstar Farm Llc (Mgr: J Mullikin)  " dob="2014-08-11T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator=""/&gt;
    &lt;nomination number="2" saddlecloth="2" horse="Condor Heroes" id="207750" idnumber="" regnumber="" blinkers="0" trainernumber="685" trainersurname="Ryan" trainerfirstname="Gerald" trainertrack="Rosehill" rsbtrainername="Gerald Ryan" jockeynumber="40275" jockeysurname="Clark" jockeyfirstname="Tim" barrier="10" weight="56" rating="0" description="B C 2 Not a Single Doubt x Gosetgo (More Than Ready(USA))" colours="Yellow, Red Sun Logo, Red Epaulettes, Hooped Sleeves, Red Cap With Gold Logo" owners="Sun Bloodstock Pty Ltd (Mgr:  Ms M C Cheng)" dob="2014-09-29T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator=""/&gt;
    &lt;nomination number="4" saddlecloth="4" horse="Invader" id="207745" idnumber="" regnumber="" blinkers="0" trainernumber="81215" trainersurname="" trainerfirstname="" trainertrack="Randwick" rsbtrainername="Peter &amp;amp; Paul Snowden" jockeynumber="331" jockeysurname="Brown" jockeyfirstname="Corey" barrier="9" weight="56" rating="0" description="CH C 2 Snitzel x Flame of Sydney (Encosta de Lago)" colours="Red, Yellow Stars And Halved Sleeves, Red And Yellow Star Cap" owners="Newgate S F (Mgr: G D Murphy), Aquis Farm (Mgr: Miss K A Fogden), China Horse Club Racing Pty Ltd (Mgr: A K Teo), Horse Ventures (Mgr: M B Sandblom) &amp;amp; Winstar Farm Llc (Mgr: J Mullikin)" dob="2014-10-01T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator=""/&gt;
    &lt;nomination number="5" saddlecloth="5" horse="Khan" id="207711" idnumber="" regnumber="" blinkers="0" trainernumber="81215" trainersurname="" trainerfirstname="" trainertrack="Randwick" rsbtrainername="Peter &amp;amp; Paul Snowden" jockeynumber="40133" jockeysurname="Shinn" jockeyfirstname="Blake" barrier="1" weight="56" rating="0" description="CH C 2 Exceed And Excel x Mandawara(FR) (Daylami(IRE))" colours="Dark Green, Gold Epaulettes" owners="James Harron Bloodstock Colts, Mrs B C Bateman, Love Racing, Doyles Breeding &amp;amp; Racing, P Mehrten, Rockingham Thoroughbreds, J A &amp;amp; Mrs F A Ingham, G1G Racing &amp;amp; Breeding &amp;amp; N Gillard" dob="2014-08-09T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator=""/&gt;
    &lt;nomination number="6" saddlecloth="6" horse="Medal Kun" id="207681" idnumber="" regnumber="" blinkers="0" trainernumber="81483" trainersurname="Cummings" trainerfirstname="James" trainertrack="Randwick" rsbtrainername="James Cummings" jockeynumber="336" jockeysurname="Boss" jockeyfirstname="Glen" barrier="7" weight="56" rating="0" description="BR C 2 Medaglia D'oro(USA) x Run for Roses (Danehill(USA))" colours="Red, Black Stripes" owners="Gooree Stud (Mgr: E M Cojuangco)" dob="2014-09-30T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator=""/&gt;
    &lt;nomination number="7" saddlecloth="7" horse="Misty Lad" id="207698" idnumber="" regnumber="" blinkers="1" trainernumber="81637" trainersurname="" trainerfirstname="" trainertrack="Randwick" rsbtrainername="Gai Waterhouse &amp;amp; Adrian Bott" jockeynumber="349" jockeysurname="Bowman" jockeyfirstname="Hugh" barrier="5" weight="56" rating="0" description="B C 2 Redoute's Choice x Anadan (Anabaa(USA))" colours="Gold, Purple Star, Gold And White Stars Sleeves, Purple Cap" owners="Mt Hallowell Stud (Mgr: C G Thompson) &amp;amp; D K M Walpole " dob="2014-10-09T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator=""/&gt;
    &lt;nomination number="8" saddlecloth="8" horse="Opulentus" id="207699" idnumber="" regnumber="" blinkers="1" trainernumber="81215" trainersurname="" trainerfirstname="" trainertrack="Randwick" rsbtrainername="Peter &amp;amp; Paul Snowden" jockeynumber="84015" jockeysurname="Avdulla" jockeyfirstname="Brenton" barrier="8" weight="56" rating="0" description="CH C 2 Choisir x Aurum Valley (Made of Gold(USA))" colours="Dark Green, Gold Epaulettes" owners="James Harron Bloodstock Colts, Mrs B C Bateman, Love Racing, Doyles Breeding &amp;amp; Racing, P Mehrten, Rockingham Thoroughbreds, J A &amp;amp; Mrs F A Ingham, G1G Racing &amp;amp; Breeding, S N Gillard, Archer Racing, Mrs C J Inglis, D Saab &amp;amp; Platinum Breeding &amp;amp; Racing" dob="2014-08-24T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator=""/&gt;
    &lt;nomination number="9" saddlecloth="9" horse="Piracy" id="207724" idnumber="" regnumber="" blinkers="0" trainernumber="235" trainersurname="O'Shea" trainerfirstname="John" trainertrack="Agnes Banks/Hawkesbury" rsbtrainername="John O'Shea" jockeynumber="86876" jockeysurname="McDonald" jockeyfirstname="James" barrier="12" weight="56" rating="0" description="B C 2 Exceed And Excel x Plagiarize (Stravinsky(USA))" colours="Royal Blue" owners="Godolphin" dob="2014-09-25T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator=""/&gt;
    &lt;nomination number="10" saddlecloth="10" horse="Prophet's Voice" id="207523" idnumber="" regnumber="" blinkers="0" trainernumber="7626" trainersurname="Sharah" trainerfirstname="John" trainertrack="Warwick Farm" rsbtrainername="John Sharah" jockeynumber="57544" jockeysurname="Hyeronimus" jockeyfirstname="Adam" barrier="2" weight="56" rating="0" description="B C 2 Poet's Voice(GB) x Gold Beauty (Street Cry(IRE))" colours="Black, White Hooped Sleeves And Cap" owners="J M Sharah " dob="2014-10-15T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator=""/&gt;
    &lt;nomination number="11" saddlecloth="11" horse="Showtime" id="207713" idnumber="" regnumber="" blinkers="0" trainernumber="77974" trainersurname="Hawkes" trainerfirstname="Michael" trainertrack="Rosehill" rsbtrainername="Michael, Wayne &amp;amp; John Hawkes" jockeynumber="51661" jockeysurname="Berry" jockeyfirstname="Tommy" barrier="14" weight="56" rating="0" description="CH C 2 Snitzel x Flidais (Timber Country(USA))" colours="Red, Yellow Stripes, Black Sleeves, Red And Yellow Striped Cap" owners="Arrowfield Pastoral Syndicate (Mgr: J M Messara), K Yoshida, Belford Productions Syndicate (Mgr: A B Jones), Pinecliff Racing Syndicate (Mgr: J B Munz), Koundouris Bloodstock Syndicate (Mgr: A E Koundouris), J G Moore &amp;amp; G P I Racing Syndicate (Mgr: G P Ingham)" dob="2014-09-21T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator=""/&gt;
    &lt;nomination number="12" saddlecloth="12" horse="Spencer" id="207700" idnumber="" regnumber="" blinkers="1" trainernumber="38701" trainersurname="Cummings" trainerfirstname="Anthony" trainertrack="Randwick" rsbtrainername="Anthony Cummings" jockeynumber="57688" jockeysurname="Schofield" jockeyfirstname="Glyn" barrier="6" weight="56" rating="0" description="B C 2 Pierro x Alice's Smart(USA) (Smart Strike(CAN))" colours="Yellow, Red Quarters, Red and White Checked Armbands And Checked Cap" owners="Edinburgh Park (I Smith), S Bennett, C Battese, S K Bennett, P R A Falk, M J Hayne  B A Rutter, Glenrock (H Cooper) &amp;amp; Monaro Bloodstock (R J Logan)" dob="2014-09-28T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator=""/&gt;
    &lt;nomination number="13" saddlecloth="13" horse="The Mission" id="207726" idnumber="" regnumber="" blinkers="0" trainernumber="318" trainersurname="Perry" trainerfirstname="Paul" trainertrack="Newcastle" rsbtrainername="Paul Perry" jockeynumber="48503" jockeysurname="Williams" jockeyfirstname="Craig" barrier="4" weight="56" rating="0" description="B C 2 Choisir x My Amelia (Redoute's Choice)" colours="Yellow, Black Sash, Armbands And Cap" owners="Ms C G Collis, Mrs B J Grant, Mrs J P Poole &amp;amp; Mrs D M McCarthy" dob="2014-09-07T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator=""/&gt;
    &lt;nomination number="14" saddlecloth="14" horse="Thy Kingdom Come" id="207685" idnumber="" regnumber="" blinkers="0" trainernumber="77972" trainersurname="Thompson" trainerfirstname="John P" trainertrack="Randwick" rsbtrainername="John P Thompson" jockeynumber="46930" jockeysurname="Angland" jockeyfirstname="Tye" barrier="11" weight="56" rating="0" description="CH C 2 Lope de Vega(IRE) x Family Jewels (Secret Savings(USA))" colours="Royal Blue And Gold Diagonal Stripes, White Cap And Pom Pom" owners="Francis Racing (Mgr: J Francis), Dr K P Rewell, G Bakhos, M J Grace, T Khoury &amp;amp; B D Lawrence " dob="2014-08-01T00:00:00" age="2" sex="C" career="0-0-0-0" thistrack="0-0-0-0" thisdistance="0-0-0-0" goodtrack="0-0-0-0" heavytrack="0-0-0-0" slowtrack="" deadtrack="" fasttrack="0-0-0-0" firstup="0-0-0-0" secondup="0-0-0-0" mindistancewin="0" maxdistancewin="0" finished="0" weightvariation="0" variedweight="56" decimalmargin="0.00" penalty="0" pricestarting="" sectional200="0" sectional400="0" sectional600="0" sectional800="0" sectional1200="0" bonusindicator=""/&gt;
&lt;/race&gt;
</code></pre>

<p>As you can see, no nomination element with <code>number="0"</code> left.</p>

<p>The problem must be in the way you write the filtered data.</p>

python