Stripping Annotations

Here are some examples of how to remove annotations from an xml document

Remove annotation elements from an sbml document in Python
from pyomexmeta import RDF, Editor

sbml = """<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1">
    <model metaid="ToyModel" id="ToyModel">
        <listOfCompartments>
            <compartment id="cytosol" metaid="comp1" spatialDimensions="3" size="1" constant="true"/>
            <compartment id="extraCell" metaid="comp2" spatialDimensions="3" size="10" constant="true"/>
        </listOfCompartments>
        <listOfSpecies>
            <species id="A" metaid="sp_1" compartment="cytosol" initialConcentration="10" hasOnlySubstanceUnits="false"
                     boundaryCondition="false" constant="false">
                <annotation>
                    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                             xmlns:bqbiol="http://biomodels.net/biology-qualifiers/">
                        <rdf:Description rdf:about="#DescriptionAnnotationWithBag">
                            <bqbiol:is>
                                <rdf:Bag>
                                    <rdf:li rdf:resource="http://identifiers.org/uniprot/P00742"/>
                                    <rdf:li rdf:resource="http://identifiers.org/uniprot/P00743"/>
                                </rdf:Bag>
                            </bqbiol:is>
                        </rdf:Description>
                    </rdf:RDF>
                </annotation>
            </species>
            <species id="B" metaid="sp_2" compartment="cytosol" initialConcentration="0" hasOnlySubstanceUnits="false"
                     boundaryCondition="false" constant="false"/>
            <species id="Ca" metaid="sp_3" compartment="cytosol" initialConcentration="2" hasOnlySubstanceUnits="false"
                     boundaryCondition="false" constant="false"/>
            <species id="PlasmaCa" metaid="sp_4" compartment="extraCell" initialConcentration="3"
                     hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
            <species id="Enzyme" metaid="sp_5" compartment="cytosol" initialConcentration="2"
                     hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
        </listOfSpecies>
        <listOfParameters>
            <parameter id="k1" value="0.1" constant="true"/>
            <parameter id="k2" value="0.1" constant="true"/>
        </listOfParameters>
        <listOfReactions>
            <reaction id="r1" metaid="react1" reversible="false" fast="false">
                <listOfReactants>
                    <speciesReference species="B" stoichiometry="1" constant="true"/>
                </listOfReactants>
                <listOfProducts>
                    <speciesReference species="A" stoichiometry="2" constant="true"/>
                </listOfProducts>
                <kineticLaw>
                    <math xmlns="http://www.w3.org/1998/Math/MathML">
                        <apply>
                            <times/>
                            <ci>k2</ci>
                            <ci>B</ci>
                        </apply>
                    </math>
                </kineticLaw>
            </reaction>
            <reaction id="r2" metaid="react2" reversible="false" fast="false">
                <listOfReactants>
                    <speciesReference species="Ca" stoichiometry="1" constant="true"/>
                    <speciesReference species="A" stoichiometry="1" constant="true"/>
                </listOfReactants>
                <listOfProducts>
                    <speciesReference species="PlasmaCa" stoichiometry="1" constant="true"/>
                </listOfProducts>
                <listOfModifiers>
                    <modifierSpeciesReference species="Enzyme"/>
                </listOfModifiers>
                <kineticLaw>
                    <math xmlns="http://www.w3.org/1998/Math/MathML">
                        <apply>
                            <times/>
                            <ci>k2</ci>
                            <ci>Ca</ci>
                        </apply>
                    </math>
                </kineticLaw>
            </reaction>
        </listOfReactions>
    </model>
</sbml>"""

rdf = RDF()
editor = rdf.to_editor(sbml, False)
print(editor.strip_annotations())

Output
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1">
    <model metaid="ToyModel" id="ToyModel">
        <listOfCompartments>
            <compartment id="cytosol" metaid="comp1" spatialDimensions="3" size="1" constant="true"/>
            <compartment id="extraCell" metaid="comp2" spatialDimensions="3" size="10" constant="true"/>
        </listOfCompartments>
        <listOfSpecies>
            <species id="A" metaid="sp_1" compartment="cytosol" initialConcentration="10" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false">
                
            </species>
            <species id="B" metaid="sp_2" compartment="cytosol" initialConcentration="0" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
            <species id="Ca" metaid="sp_3" compartment="cytosol" initialConcentration="2" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
            <species id="PlasmaCa" metaid="sp_4" compartment="extraCell" initialConcentration="3" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
            <species id="Enzyme" metaid="sp_5" compartment="cytosol" initialConcentration="2" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
        </listOfSpecies>
        <listOfParameters>
            <parameter id="k1" value="0.1" constant="true"/>
            <parameter id="k2" value="0.1" constant="true"/>
        </listOfParameters>
        <listOfReactions>
            <reaction id="r1" metaid="react1" reversible="false" fast="false">
                <listOfReactants>
                    <speciesReference species="B" stoichiometry="1" constant="true"/>
                </listOfReactants>
                <listOfProducts>
                    <speciesReference species="A" stoichiometry="2" constant="true"/>
                </listOfProducts>
                <kineticLaw>
                    <math xmlns="http://www.w3.org/1998/Math/MathML">
                        <apply>
                            <times/>
                            <ci>k2</ci>
                            <ci>B</ci>
                        </apply>
                    </math>
                </kineticLaw>
            </reaction>
            <reaction id="r2" metaid="react2" reversible="false" fast="false">
                <listOfReactants>
                    <speciesReference species="Ca" stoichiometry="1" constant="true"/>
                    <speciesReference species="A" stoichiometry="1" constant="true"/>
                </listOfReactants>
                <listOfProducts>
                    <speciesReference species="PlasmaCa" stoichiometry="1" constant="true"/>
                </listOfProducts>
                <listOfModifiers>
                    <modifierSpeciesReference species="Enzyme"/>
                </listOfModifiers>
                <kineticLaw>
                    <math xmlns="http://www.w3.org/1998/Math/MathML">
                        <apply>
                            <times/>
                            <ci>k2</ci>
                            <ci>Ca</ci>
                        </apply>
                    </math>
                </kineticLaw>
            </reaction>
        </listOfReactions>
    </model>
</sbml>