lxml: add namespace to input file

后端 未结 6 1547
不思量自难忘°
不思量自难忘° 2020-12-03 21:16

I am parsing an xml file generated by an external program. I would then like to add custom annotations to this file, using my own namespace. My input looks as below:

6条回答
  •  感情败类
    2020-12-03 21:38

    Rather than dealing directly with the raw XML you could also look toward LibSBML, a library for manipulating SBML documents with language bindings for, among others, python. There you would use it like this:

    >>> from libsbml import *
    >>> doc = readSBML('Dropbox/SBML Models/BorisEJB.xml')
    >>> species = doc.getModel().getSpecies('MAPK')
    >>> species.appendAnnotation('')
    0
    >>> species.toSBML()
    '\n  \n
     \n  \n'
    >>>
    
    

提交回复
热议问题