opensimXmlInterface#
- class pyCGM2.Model.Opensim.interface.opensimInterface.opensimXmlInterface(templateFullFilename: str, outFullFilename: str | None = None)#
- Interface for interacting with OpenSim XML files. - Parameters:
- templateFullFilename (str) – Filename of the template OpenSim XML file. 
- outFullFilename (Optional[str]) – Filename for the output file. If None, derived from templateFullFilename. 
 
 - __init__(templateFullFilename: str, outFullFilename: str | None = None)#
 - Methods - __init__(templateFullFilename[, outFullFilename])- getSoup()- Retrieves the BeautifulSoup object for XML parsing. - set_inList_fromAttr(listName, label, ...)- Sets the text for XML elements within a list based on an attribute's value. - set_many(label, text)- Sets the text for all XML elements with a specific label. - set_many_inList(listName, label, text)- Sets the text for all XML elements within a list with a specific label. - set_one(labels, text)- Sets the text for a specific XML element or a path of elements. - update()- Updates the XML file with changes made to the BeautifulSoup object. - getSoup() BeautifulSoup#
- Retrieves the BeautifulSoup object for XML parsing. - Returns:
- BeautifulSoup – BeautifulSoup object for the OpenSim XML file. 
 
 - set_inList_fromAttr(listName: str, label: str, attrKey: str, attrValue: str, text: str) None#
- Sets the text for XML elements within a list based on an attribute’s value. - Parameters:
- listName (str) – The label of the list in the XML. 
- label (str) – The label of the XML elements within the list. 
- attrKey (str) – The attribute key to match. 
- attrValue (str) – The value of the attribute to match. 
- text (str) – The text to set for the matching XML elements. 
 
 
 - set_many(label: str, text: str) None#
- Sets the text for all XML elements with a specific label. - Parameters:
- label (str) – The label of the XML elements. 
- text (str) – The text to set for each XML element. 
 
 
 - set_many_inList(listName: str, label: str, text: str) None#
- Sets the text for all XML elements within a list with a specific label. - Parameters:
- listName (str) – The label of the list in the XML. 
- label (str) – The label of the XML elements within the list. 
- text (str) – The text to set for each XML element in the list. 
 
 
 - set_one(labels: str | List[str], text: str) None#
- Sets the text for a specific XML element or a path of elements. - Parameters:
- labels (Union[str, List[str]]) – The label or path of labels leading to the XML element. 
- text (str) – The text to set for the XML element. 
 
 
 - update()#
- Updates the XML file with changes made to the BeautifulSoup object. - Writes the updated XML content to the output file specified in m_out. 
 
