Python Forum
parsing values and writing back in xml file - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: parsing values and writing back in xml file (/thread-4816.html)



parsing values and writing back in xml file - deepa - Sep-10-2017

Hi All,
I am attempting to parse the values from an xml file ,modify these vales and re-write the new values back into the xml file.
I have parsed the parameter values using libSBML.I wish to update the xml file with the new values of the parameter.
I couldn't find out how to write back the new values in xml file.

I would like to get some help to do this task.



Thanks again,
Deepa


RE: parsing values and writing back in xml file - nilamo - Sep-10-2017

I'm confused.  If you've parsed the file, then you have an object that represents the xml file.  XML is just a text file.  So... does libsbml have write functionality?

There isn't really such a thing as "updating" a value in a file.  You either write the file, or you don't.  You aren't going to just write part of it.


RE: parsing values and writing back in xml file - deepa - Sep-11-2017

I have parsed only parameter values present in the file.
The following is a tag in my xml file,
<parameter id="G6PASE_Vmax" constant="true" value="18.9" units="mmol_per_s"/>
There are 30 such id's with a value corresponding to each.And I wish to change the value.
I have parsed the parameter id and the value using libsbml in python.Now, how do we write these new values back into the file?
Yes,libsbml has has write functionality.
I wish to obtain the xml file with new values against each parameter id.


RE: parsing values and writing back in xml file - nilamo - Sep-11-2017

Could you provide a small example of the input file (3 lines would be plenty), along with how you're currently parsing it (again, 5 lines is probably all it'd take)?  That way it's easier to help (otherwise, I'm just guessing).


RE: parsing values and writing back in xml file - deepa - Sep-11-2017

Hi,
Please find the input file in the following link,
https://github.com/matthiaskoenig/glucose-model/blob/master/sbml/Koenig2014_Hepatic_Glucose_Model.xml

The python code is found in the following link,
https://github.com/DeepaMahm/cytoscape/blob/master/parameter_parse.py

Thanks