
Beginning with version 3.0.0, libSBML implements an XML abstraction layer. This layer presents a uniform XML interface to calling programs regardless of which underlying XML parser libSBML has actually been configured to use. The basic data object in the XML abstraction is a node, represented by XMLNode.
An XMLNode can contain any number of children. Each child is another XMLNode, thereby forming a tree. The methods XMLNode.getNumChildren() and
Each XMLNode is subclassed from XMLToken, and thus has the same methods available as XMLToken. These methods include XMLToken.getNamespaces(), XMLToken.getPrefix(), XMLToken.getName(), XMLToken.getURI(), and XMLToken.getAttributes().
The returned XMLNode object by XMLNode.convertStringToXMLNode() is a dummy root (container) XMLNode if the given XML string has two or more top-level elements (e.g., '<p>...</p><p>...</p>'). In the dummy root node, each top-level element in the given XML string is contained as a child XMLNode. XMLToken.isEOF() can be used to identify if the returned XMLNode object is a dummy node or not. Here is an example:
Definition at line 28651 of file libsbml.py.
| def libsbml.XMLToken.__eq__ | ( | self, | ||
| rhs | ||||
| ) | [inherited] |
Definition at line 28634 of file libsbml.py.
| def libsbml.XMLNode.__init__ | ( | self, | ||
| args | ||||
| ) |
Python method signature(s):
__init__(self)XMLNode __init__(self, XMLToken token)
XMLNode __init__(self, XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces, unsigned int line = 0, unsigned int column = 0)
XMLNode __init__(self, XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces, unsigned int line = 0)
XMLNode __init__(self, XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces)
XMLNode __init__(self, XMLTriple triple, XMLAttributes attributes, unsigned int line = 0, unsigned int column = 0)
XMLNode __init__(self, XMLTriple triple, XMLAttributes attributes, unsigned int line = 0)
XMLNode __init__(self, XMLTriple triple, XMLAttributes attributes)
XMLNode __init__(self, XMLTriple triple, unsigned int line = 0, unsigned int column = 0)
XMLNode __init__(self, XMLTriple triple, unsigned int line = 0)
XMLNode __init__(self, XMLTriple triple)
XMLNode __init__(self, string chars, unsigned int line = 0, unsigned int column = 0)
XMLNode __init__(self, string chars, unsigned int line = 0)
XMLNode __init__(self, string chars)
XMLNode __init__(self, XMLNode orig)
XMLNode
Copy constructor; creates a copy of this XMLNode.
| orig | the XMLNode instance to copy. |
Reimplemented from libsbml.XMLToken.
Definition at line 28756 of file libsbml.py.
| def libsbml.XMLToken.__ne__ | ( | self, | ||
| rhs | ||||
| ) | [inherited] |
Definition at line 28641 of file libsbml.py.
| def libsbml.XMLToken.addAttr | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
addAttr(self, string name, string value, string namespaceURI = "", string prefix = "")int addAttr(self, string name, string value, string namespaceURI = "")
int addAttr(self, string name, string value)
int addAttr(self, XMLTriple triple, string value)
int
Adds an attribute with the given XMLTriple/value pair to the attribute set in this XMLToken. Nothing will be done if this XMLToken is not a start element.
| triple | an XMLTriple, the XML triple of the attribute. | |
| value | a string, the value of the attribute. |
Definition at line 27739 of file libsbml.py.
| def libsbml.XMLNode.addChild | ( | self, | ||
| args | ||||
| ) |
Python method signature(s):
addChild(self, XMLNode node)int
Adds a copy of node as a child of this XMLNode.
The given node is added at the end of the list of children.
| node | the XMLNode to be added as child. |
Definition at line 28804 of file libsbml.py.
| def libsbml.XMLToken.addNamespace | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
addNamespace(self, string uri, string prefix = "")int addNamespace(self, string uri)
int
Appends an XML namespace prefix and URI pair to this XMLToken. If there is an XML namespace with the given prefix in this XMLToken, then the existing XML namespace will be overwritten by the new one.
Nothing will be done if this XMLToken is not a start element.
Definition at line 28052 of file libsbml.py.
| def libsbml.XMLToken.append | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
append(self, string chars)int
Appends characters to this XML text content.
| chars | string, characters to append |
Definition at line 28406 of file libsbml.py.
| def libsbml.XMLToken.clearAttributes | ( | self | ) | [inherited] |
Python method signature(s):
clearAttributes(self)int
Clears (deletes) all attributes in this XMLToken. Nothing will be done if this XMLToken is not a start element.
Definition at line 27799 of file libsbml.py.
| def libsbml.XMLToken.clearNamespaces | ( | self | ) | [inherited] |
Python method signature(s):
clearNamespaces(self)int
Clears (deletes) all XML namespace declarations in the XMLNamespaces of this XMLToken. Nothing will be done if this XMLToken is not a start element.
Definition at line 28117 of file libsbml.py.
| def libsbml.XMLNode.clone | ( | self | ) |
Python method signature(s):
clone(self)XMLNode
Creates and returns a deep copy of this XMLNode.
Reimplemented from libsbml.XMLToken.
Definition at line 28789 of file libsbml.py.
| def libsbml.XMLNode.convertStringToXMLNode | ( | args | ) |
Python method signature(s):
convertStringToXMLNode(string xmlstr, XMLNamespaces xmlns = None)XMLNode convertStringToXMLNode(string xmlstr)
XMLNode
Returns an XMLNode which is derived from a string containing XML content.
The XML namespace must be defined using argument xmlns if the corresponding XML namespace attribute is not part of the string of the first argument.
| xmlstr | string to be converted to a XML node. | |
| xmlns | XMLNamespaces the namespaces to set (default value is NULL). |
html, body, annotation, notes. In the dummy root node, each top-level element in the given XML string is contained as a child XMLNode. XMLToken.isEOF() can be used to identify if the returned XMLNode object is a dummy node.Definition at line 28968 of file libsbml.py.
| def libsbml.XMLNode.convertXMLNodeToString | ( | args | ) |
| def libsbml.XMLToken.getAttributes | ( | self | ) | [inherited] |
Python method signature(s):
getAttributes(self)XMLAttributes
Returns the attributes of this element.
Definition at line 27699 of file libsbml.py.
| def libsbml.XMLToken.getAttributesLength | ( | self | ) | [inherited] |
Python method signature(s):
getAttributesLength(self)int
Return the number of attributes in the attributes set.
Definition at line 27840 of file libsbml.py.
| def libsbml.XMLToken.getAttrIndex | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
getAttrIndex(self, string name, string uri = "")int getAttrIndex(self, string name)
int getAttrIndex(self, XMLTriple triple)
int
Return the index of an attribute with the given XMLTriple.
| triple | an XMLTriple, the XML triple of the attribute for which the index is required. |
Definition at line 27820 of file libsbml.py.
| def libsbml.XMLToken.getAttrName | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
getAttrName(self, int index)string
Return the local name of an attribute in the attributes set in this XMLToken (by position).
| index | an integer, the position of the attribute whose local name is required. |
Definition at line 27855 of file libsbml.py.
| def libsbml.XMLToken.getAttrPrefix | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
getAttrPrefix(self, int index)string
Return the prefix of an attribute in the attribute set in this XMLToken (by position).
| index | an integer, the position of the attribute whose prefix is required. |
Definition at line 27878 of file libsbml.py.
| def libsbml.XMLToken.getAttrPrefixedName | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
getAttrPrefixedName(self, int index)string
Return the prefixed name of an attribute in the attribute set in this XMLToken (by position).
| index | an integer, the position of the attribute whose prefixed name is required. |
Definition at line 27901 of file libsbml.py.
| def libsbml.XMLToken.getAttrURI | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
getAttrURI(self, int index)string
Return the namespace URI of an attribute in the attribute set in this XMLToken (by position).
| index | an integer, the position of the attribute whose namespace URI is required. |
Definition at line 27924 of file libsbml.py.
| def libsbml.XMLToken.getAttrValue | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
getAttrValue(self, int index)string getAttrValue(self, string name, string uri = "")
string getAttrValue(self, string name)
string getAttrValue(self, XMLTriple triple)
string
Return a value of an attribute with the given XMLTriple.
| triple | an XMLTriple, the XML triple of the attribute whose value is required. |
Definition at line 27946 of file libsbml.py.
| def libsbml.XMLToken.getCharacters | ( | self | ) | [inherited] |
Python method signature(s):
getCharacters(self)string
Returns the text of this element.
Definition at line 28391 of file libsbml.py.
| def libsbml.XMLNode.getChild | ( | self, | ||
| args | ||||
| ) |
Python method signature(s):
getChild(self, unsigned int n)XMLNode getChild(self, unsigned int n)
XMLNode
Returns the nth child of this XMLNode.
If the index n is greater than the number of child nodes, or it is 0 or less, this method returns an empty node.
| n | an integer, the index of the node to return |
nth child of this XMLNode. Definition at line 28898 of file libsbml.py.
| def libsbml.XMLToken.getColumn | ( | self | ) | [inherited] |
Python method signature(s):
getColumn(self)unsigned int
Returns the column at which this XMLToken occurred in the input document or data stream.
Definition at line 28428 of file libsbml.py.
| def libsbml.XMLToken.getLine | ( | self | ) | [inherited] |
Python method signature(s):
getLine(self)unsigned int
Returns the line at which this XMLToken occurred in the input document or data stream.
Definition at line 28444 of file libsbml.py.
| def libsbml.XMLToken.getName | ( | self | ) | [inherited] |
Python method signature(s):
getName(self)string
Returns the (unqualified) name of this XML element.
Definition at line 28343 of file libsbml.py.
| def libsbml.XMLToken.getNamespaceIndex | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
getNamespaceIndex(self, string uri)int
Look up the index of an XML namespace declaration by URI.
| uri | a string, uri of the required namespace. |
Definition at line 28139 of file libsbml.py.
| def libsbml.XMLToken.getNamespaceIndexByPrefix | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
getNamespaceIndexByPrefix(self, string prefix)int
Look up the index of an XML namespace declaration by prefix.
| prefix | a string, prefix of the required namespace. |
Definition at line 28156 of file libsbml.py.
| def libsbml.XMLToken.getNamespacePrefix | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
getNamespacePrefix(self, int index)string getNamespacePrefix(self, string uri)
string
Look up the prefix of an XML namespace declaration by its URI.
| uri | a string, the URI of the prefix being sought |
uri does not exist, an empty string will be returned. Definition at line 28189 of file libsbml.py.
| def libsbml.XMLToken.getNamespaces | ( | self | ) | [inherited] |
Python method signature(s):
getNamespaces(self)XMLNamespaces
Returns the XML namespace declarations for this XML element.
Definition at line 28012 of file libsbml.py.
| def libsbml.XMLToken.getNamespacesLength | ( | self | ) | [inherited] |
Python method signature(s):
getNamespacesLength(self)int
Returns the number of XML namespaces stored in the XMLNamespaces of this XMLToken.
Definition at line 28173 of file libsbml.py.
| def libsbml.XMLToken.getNamespaceURI | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
getNamespaceURI(self, int index)string getNamespaceURI(self, string prefix = "")
string getNamespaceURI(self)
string
Look up the URI of an XML namespace declaration by its prefix.
| prefix | a string, the prefix of the required URI |
prefix does not exist, an empty string will be returned.Definition at line 28209 of file libsbml.py.
| def libsbml.XMLNode.getNumChildren | ( | self | ) |
Python method signature(s):
getNumChildren(self)unsigned int
Returns the number of children for this XMLNode.
Definition at line 28919 of file libsbml.py.
| def libsbml.XMLToken.getPrefix | ( | self | ) | [inherited] |
Python method signature(s):
getPrefix(self)string
Returns the namespace prefix of this XML element.
Definition at line 28358 of file libsbml.py.
| def libsbml.XMLToken.getURI | ( | self | ) | [inherited] |
Python method signature(s):
getURI(self)string
Returns the namespace URI of this XML element.
Definition at line 28376 of file libsbml.py.
| def libsbml.XMLToken.hasAttr | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
hasAttr(self, int index)bool hasAttr(self, string name, string uri = "")
bool hasAttr(self, string name)
bool hasAttr(self, XMLTriple triple)
bool
Predicate returning true or false depending on whether an attribute with the given XML triple exists in the attribute set in this XMLToken
| triple | an XMLTriple, the XML triple of the attribute |
true if an attribute with the given XML triple exists in the attribute set in this XMLToken, false otherwise. Definition at line 27971 of file libsbml.py.
| def libsbml.XMLToken.hasNamespaceNS | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
hasNamespaceNS(self, string uri, string prefix)bool
Predicate returning true or false depending on whether an XML Namespace with the given uri/prefix pair is contained in the XMLNamespaces ofthis XMLToken.
true if an XML Namespace with the given uri/prefix pair is contained in the XMLNamespaces of this XMLToken, false otherwise. Definition at line 28299 of file libsbml.py.
| def libsbml.XMLToken.hasNamespacePrefix | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
hasNamespacePrefix(self, string prefix)bool
Predicate returning true or false depending on whether an XML Namespace with the given prefix is contained in the XMLNamespaces of this XMLToken.
| prefix | a string, the prefix for the namespace |
true if an XML Namespace with the given URI is contained in the XMLNamespaces of this XMLToken, false otherwise. Definition at line 28279 of file libsbml.py.
| def libsbml.XMLToken.hasNamespaceURI | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
hasNamespaceURI(self, string uri)bool
Predicate returning true or false depending on whether an XML Namespace with the given URI is contained in the XMLNamespaces of this XMLToken.
| uri | a string, the uri for the namespace |
true if an XML Namespace with the given URI is contained in the XMLNamespaces of this XMLToken, false otherwise. Definition at line 28259 of file libsbml.py.
| def libsbml.XMLNode.insertChild | ( | self, | ||
| args | ||||
| ) |
Python method signature(s):
insertChild(self, unsigned int n, XMLNode node)XMLNode
Inserts a copy of the given node as the nth child of this XMLNode.
If the given index n is out of range for this XMLNode instance, the node is added at the end of the list of children. Even in that situation, this method does not throw an error.
| n | an integer, the index at which the given node is inserted | |
| node | an XMLNode to be inserted as nth child. |
node Definition at line 28830 of file libsbml.py.
| def libsbml.XMLToken.isAttributesEmpty | ( | self | ) | [inherited] |
Python method signature(s):
isAttributesEmpty(self)bool
Predicate returning true or false depending on whether the attribute set in this XMLToken set is empty.
true if the attribute set in this XMLToken is empty, false otherwise. Definition at line 27995 of file libsbml.py.
| def libsbml.XMLToken.isElement | ( | self | ) | [inherited] |
Python method signature(s):
isElement(self)bool
Predicate returning true or false depending on whether this XMLToken is an XML element.
true if this XMLToken is an XML element, false otherwise. Definition at line 28460 of file libsbml.py.
| def libsbml.XMLToken.isEnd | ( | self | ) | [inherited] |
Python method signature(s):
isEnd(self)bool
Predicate returning true or false depending on whether this XMLToken is an XML end element.
true if this XMLToken is an XML end element, false otherwise. Definition at line 28476 of file libsbml.py.
| def libsbml.XMLToken.isEndFor | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
isEndFor(self, XMLToken element)bool
Predicate returning true or false depending on whether this XMLToken is an XML end element for the given start element.
| element | XMLToken, element for which query is made. |
true if this XMLToken is an XML end element for the given XMLToken start element, false otherwise. Definition at line 28492 of file libsbml.py.
| def libsbml.XMLToken.isEOF | ( | self | ) | [inherited] |
Python method signature(s):
isEOF(self)bool
Predicate returning true or false depending on whether this XMLToken is an end of file marker.
true if this XMLToken is an end of file (input) marker, false otherwise. Definition at line 28511 of file libsbml.py.
| def libsbml.XMLToken.isNamespacesEmpty | ( | self | ) | [inherited] |
Python method signature(s):
isNamespacesEmpty(self)bool
Predicate returning true or false depending on whether the XMLNamespaces of this XMLToken is empty.
true if the XMLNamespaces of this XMLToken is empty, false otherwise. Definition at line 28242 of file libsbml.py.
| def libsbml.XMLToken.isStart | ( | self | ) | [inherited] |
Python method signature(s):
isStart(self)bool
Predicate returning true or false depending on whether this XMLToken is an XML start element.
true if this XMLToken is an XML start element, false otherwise. Definition at line 28528 of file libsbml.py.
| def libsbml.XMLToken.isText | ( | self | ) | [inherited] |
Python method signature(s):
isText(self)bool
Predicate returning true or false depending on whether this XMLToken is an XML text element.
true if this XMLToken is an XML text element, false otherwise. Definition at line 28544 of file libsbml.py.
| def libsbml.XMLToken.removeAttr | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
removeAttr(self, int n)int removeAttr(self, string name, string uri = "")
int removeAttr(self, string name)
int removeAttr(self, XMLTriple triple)
int
Removes an attribute with the given XMLTriple from the attribute set in this XMLToken. Nothing will be done if this XMLToken is not a start element.
| triple | an XMLTriple, the XML triple of the attribute. |
Definition at line 27771 of file libsbml.py.
| def libsbml.XMLNode.removeChild | ( | self, | ||
| args | ||||
| ) |
Python method signature(s):
removeChild(self, unsigned int n)XMLNode
Removes the nth child of this XMLNode and returns the removed node.
It is important to keep in mind that a given XMLNode may have more than one child. Calling this method erases all existing references to child nodes after the given position n. If the index n is greater than the number of child nodes in this XMLNode, this method takes no action (and returns NULL).
| n | an integer, the index of the node to be removed |
n is greater than the number of children in this nodeDefinition at line 28853 of file libsbml.py.
| def libsbml.XMLNode.removeChildren | ( | self | ) |
Python method signature(s):
removeChildren(self)int
Removes all children from this node.
Definition at line 28880 of file libsbml.py.
| def libsbml.XMLToken.removeNamespace | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
removeNamespace(self, int index)int removeNamespace(self, string prefix)
int
Removes an XML Namespace with the given prefix. Nothing will be done if this XMLToken is not a start element.
| prefix | a string, prefix of the required namespace. |
Definition at line 28092 of file libsbml.py.
| def libsbml.XMLToken.setAttributes | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
setAttributes(self, XMLAttributes attributes)int
Sets an XMLAttributes to this XMLToken. Nothing will be done if this XMLToken is not a start element.
| attributes | XMLAttributes to be set to this XMLToken. |
Definition at line 27714 of file libsbml.py.
| def libsbml.XMLToken.setEnd | ( | self | ) | [inherited] |
Python method signature(s):
setEnd(self)int
Declares this XML start element is also an end element.
Definition at line 28560 of file libsbml.py.
| def libsbml.XMLToken.setEOF | ( | self | ) | [inherited] |
Python method signature(s):
setEOF(self)int
Declares this XMLToken is an end-of-file (input) marker.
Definition at line 28580 of file libsbml.py.
| def libsbml.XMLToken.setNamespaces | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
setNamespaces(self, XMLNamespaces namespaces)int
Sets an XMLnamespaces to this XML element. Nothing will be done if this XMLToken is not a start element.
| namespaces | XMLNamespaces to be set to this XMLToken. |
Definition at line 28027 of file libsbml.py.
| def libsbml.XMLToken.setTriple | ( | self, | ||
| args | ||||
| ) | [inherited] |
Python method signature(s):
setTriple(self, XMLTriple triple)int
Sets the XMLTripe (name, uri and prefix) of this XML element. Nothing will be done if this XML element is a text node.
| triple | XMLTriple to be added to this XML element. |
Definition at line 28320 of file libsbml.py.
| def libsbml.XMLToken.toString | ( | self | ) | [inherited] |
Python method signature(s):
toString(self)string
Prints a string representation of the underlying token stream, for debugging purposes.
Definition at line 28620 of file libsbml.py.
| def libsbml.XMLNode.toXMLString | ( | self | ) |
| def libsbml.XMLToken.unsetEnd | ( | self | ) | [inherited] |
Python method signature(s):
unsetEnd(self)int
Declares this XML start/end element is no longer an end element.
Definition at line 28600 of file libsbml.py.