CopperSpice API
1.9.2
|
The QDomElement class represents one element in the DOM tree. More...
Public Methods | |
QDomElement () | |
QDomElement (const QDomElement &other) | |
QString | attribute (const QString &name, const QString &defValue=QString ()) const |
QDomAttr | attributeNode (const QString &name) |
QDomAttr | attributeNodeNS (const QString &nsURI, const QString &localName) |
QString | attributeNS (const QString nsURI, const QString &localName, const QString &defValue=QString ()) const |
QDomNamedNodeMap | attributes () const |
QDomNodeList | elementsByTagName (const QString &tagname) const |
QDomNodeList | elementsByTagNameNS (const QString &nsURI, const QString &localName) const |
bool | hasAttribute (const QString &name) const |
bool | hasAttributeNS (const QString &nsURI, const QString &localName) const |
QDomNode::NodeType | nodeType () const |
QDomElement & | operator= (const QDomElement &other) |
void | removeAttribute (const QString &name) |
QDomAttr | removeAttributeNode (const QDomAttr &oldAttr) |
void | removeAttributeNS (const QString &nsURI, const QString &localName) |
void | setAttribute (const QString &name, const QString &value) |
void | setAttribute (const QString &name, double value) |
void | setAttribute (const QString &name, float value) |
void | setAttribute (const QString &name, int value) |
void | setAttribute (const QString &name, qint64 value) |
void | setAttribute (const QString &name, quint64 value) |
void | setAttribute (const QString &name, uint value) |
QDomAttr | setAttributeNode (const QDomAttr &newAttr) |
QDomAttr | setAttributeNodeNS (const QDomAttr &newAttr) |
void | setAttributeNS (const QString nsURI, const QString &qName, const QString &value) |
void | setAttributeNS (const QString nsURI, const QString &qName, double value) |
void | setAttributeNS (const QString nsURI, const QString &qName, int value) |
void | setAttributeNS (const QString nsURI, const QString &qName, qint64 value) |
void | setAttributeNS (const QString nsURI, const QString &qName, quint64 value) |
void | setAttributeNS (const QString nsURI, const QString &qName, uint value) |
void | setTagName (const QString &name) |
QString | tagName () const |
QString | text () const |
Public Methods inherited from QDomNode | |
QDomNode () | |
QDomNode (const QDomNode &other) | |
~QDomNode () | |
QDomNode | appendChild (const QDomNode &newChild) |
QDomNamedNodeMap | attributes () const |
QDomNodeList | childNodes () const |
void | clear () |
QDomNode | cloneNode (bool deep=true) const |
int | columnNumber () const |
QDomNode | firstChild () const |
QDomElement | firstChildElement (const QString &tagName=QString ()) const |
bool | hasAttributes () const |
bool | hasChildNodes () const |
QDomNode | insertAfter (const QDomNode &newChild, const QDomNode &refChild) |
QDomNode | insertBefore (const QDomNode &newChild, const QDomNode &refChild) |
bool | isAttr () const |
bool | isCDATASection () const |
bool | isCharacterData () const |
bool | isComment () const |
bool | isDocument () const |
bool | isDocumentFragment () const |
bool | isDocumentType () const |
bool | isElement () const |
bool | isEntity () const |
bool | isEntityReference () const |
bool | isNotation () const |
bool | isNull () const |
bool | isProcessingInstruction () const |
bool | isSupported (const QString &feature, const QString &version) const |
bool | isText () const |
QDomNode | lastChild () const |
QDomElement | lastChildElement (const QString &tagName=QString ()) const |
int | lineNumber () const |
QString | localName () const |
QDomNode | namedItem (const QString &name) const |
QString | namespaceURI () const |
QDomNode | nextSibling () const |
QDomElement | nextSiblingElement (const QString &tagName=QString ()) const |
QString | nodeName () const |
NodeType | nodeType () const |
QString | nodeValue () const |
void | normalize () |
bool | operator!= (const QDomNode &n) const |
QDomNode & | operator= (const QDomNode &other) |
bool | operator== (const QDomNode &n) const |
QDomDocument | ownerDocument () const |
QDomNode | parentNode () const |
QString | prefix () const |
QDomNode | previousSibling () const |
QDomElement | previousSiblingElement (const QString &tagName=QString ()) const |
QDomNode | removeChild (const QDomNode &oldChild) |
QDomNode | replaceChild (const QDomNode &newChild, const QDomNode &oldChild) |
void | save (QTextStream &stream, int indent, QDomNode::EncodingPolicy policy=QDomNode::EncodingFromDocument) const |
void | setNodeValue (const QString &value) |
void | setPrefix (const QString &prefix) |
QDomAttr | toAttr () const |
QDomCDATASection | toCDATASection () const |
QDomCharacterData | toCharacterData () const |
QDomComment | toComment () const |
QDomDocument | toDocument () const |
QDomDocumentFragment | toDocumentFragment () const |
QDomDocumentType | toDocumentType () const |
QDomElement | toElement () const |
QDomEntity | toEntity () const |
QDomEntityReference | toEntityReference () const |
QDomNotation | toNotation () const |
QDomProcessingInstruction | toProcessingInstruction () const |
QDomText | toText () const |
Friends | |
class | QDomAttr |
class | QDomDocument |
class | QDomNode |
Additional Inherited Members | |
Public Types inherited from QDomNode | |
enum | EncodingPolicy |
enum | NodeType |
Related Functions inherited from QDomNode | |
QTextStream & | operator<< (QTextStream &str, const QDomNode &node) |
The QDomElement class represents one element in the DOM tree.
Elements have a tagName() and zero or more attributes associated with them. The tag name can be changed with setTagName().
Element attributes are represented by QDomAttr objects that can be queried using the attribute() and attributeNode() functions. You can set attributes with the setAttribute() and setAttributeNode() functions. Attributes can be removed with removeAttribute(). There are namespace-aware equivalents to these functions, i.e. setAttributeNS(), setAttributeNodeNS() and removeAttributeNS().
If you want to access the text of a node use text(), e.g.
The text() function operates recursively to find the text (since not all elements contain text). If you want to find all the text in all of a node's children, iterate over the children looking for QDomText nodes, e.g.
Note that we attempt to convert each node to a text node and use text() rather than using firstChild().toText().data() or n.toText().data() directly on the node, because the node may not be a text element.
You can get a list of all the descendants of an element which have a specified tag name with elementsByTagName() or elementsByTagNameNS().
To browse the elements of a dom document use firstChildElement(), lastChildElement(), nextSiblingElement() and previousSiblingElement(). For example, to iterate over all child elements called "entry" in a root element called "database", you can use:
For further information about the Document Object Model see Level 1 and Level 2 Core. For a more general introduction of the DOM implementation see the QDomDocument documentation.
QDomElement::QDomElement | ( | ) |
Constructs an empty element. Use the QDomDocument::createElement() function to construct elements with content.
QDomElement::QDomElement | ( | const QDomElement & | other | ) |
Copy constructs a new QDomElement from other.
Returns the attribute called name. If the attribute does not exist defValue is returned.
Returns the QDomAttr object that corresponds to the attribute called name. If no such attribute exists a null attribute is returned.
QString QDomElement::attributeNS | ( | const QString | nsURI, |
const QString & | localName, | ||
const QString & | defValue = QString() |
||
) | const |
Returns the attribute with the local name localName and the namespace URI nsURI. If the attribute does not exist defValue is returned.
QDomNamedNodeMap QDomElement::attributes | ( | ) | const |
Returns a QDomNamedNodeMap containing all this element's attributes.
QDomNodeList QDomElement::elementsByTagName | ( | const QString & | tagname | ) | const |
Returns a QDomNodeList containing all descendants of this element named tagname encountered during a preorder traversal of the element subtree with this element as its root. The order of the elements in the returned list is the order they are encountered during the preorder traversal.
QDomNodeList QDomElement::elementsByTagNameNS | ( | const QString & | nsURI, |
const QString & | localName | ||
) | const |
Returns a QDomNodeList containing all descendants of this element with local name localName and namespace URI nsURI encountered during a preorder traversal of the element subtree with this element as its root. The order of the elements in the returned list is the order they are encountered during the preorder traversal.
bool QDomElement::hasAttribute | ( | const QString & | name | ) | const |
Returns true if this element has an attribute called name, otherwise returns false.
Use hasAttributeNS() to explicitly test for attributes with specific namespaces and names.
Returns true if this element has an attribute with the local name localName and the namespace URI nsURI, otherwise returns false.
|
inline |
Returns ElementNode
.
QDomElement & QDomElement::operator= | ( | const QDomElement & | other | ) |
Copy assigns from other and returns a reference to this object.
void QDomElement::removeAttribute | ( | const QString & | name | ) |
Removes the attribute called name from this element.
Removes the attribute oldAttr from the element and returns it.
Removes the attribute with the local name localName and the namespace URI nsURI from this element.
Adds an attribute called name with given value. If an attribute already exists with the specified name, then its value is replaced by the specified value.
void QDomElement::setAttribute | ( | const QString & | name, |
double | value | ||
) |
The number is formatted according to the current locale.
void QDomElement::setAttribute | ( | const QString & | name, |
float | value | ||
) |
The number is formatted according to the current locale.
|
inline |
The number is formatted according to the current locale.
The number is formatted according to the current locale.
The number is formatted according to the current locale.
The number is formatted according to the current locale.
Adds the attribute newAttr to this element. If the element has another attribute that has the same name as newAttr, this method replaces that attribute and returns it, otherwise it returns a null attribute.
Adds the attribute newAttr to this element. If the element has another attribute that has the same local name and namespace URI as newAttr this method replaces that attribute and returns it, otherwise it returns a null attribute.
void QDomElement::setAttributeNS | ( | const QString | nsURI, |
const QString & | qName, | ||
const QString & | value | ||
) |
Adds an attribute with the qualified name using the given qName, and the namespace URI nsURI with the value value. If an attribute with the same local name and namespace URI exists, the prefix is replaced by the prefix of qName and the value is replaced by value.
Although qName is the qualified name, the local name is used to decide if an existing attribute's value should be replaced.
Adds an attribute with the qualified name using the given qName, and the namespace URI nsURI with the value value. If an attribute with the same local name and namespace URI exists, the prefix is replaced by the prefix of qName and the value is replaced by value.
Although qName is the qualified name, the local name is used to decide if an existing attribute's value should be replaced.
Adds an attribute with the qualified name using the given qName, and the namespace URI nsURI with the value value. If an attribute with the same local name and namespace URI exists, the prefix is replaced by the prefix of qName and the value is replaced by value.
Although qName is the qualified name, the local name is used to decide if an existing attribute's value should be replaced.
Adds an attribute with the qualified name using the given qName, and the namespace URI nsURI with the value value. If an attribute with the same local name and namespace URI exists, the prefix is replaced by the prefix of qName and the value is replaced by value.
Although qName is the qualified name, the local name is used to decide if an existing attribute's value should be replaced.
Adds an attribute with the qualified name using the given qName, and the namespace URI nsURI with the value value. If an attribute with the same local name and namespace URI exists, the prefix is replaced by the prefix of qName and the value is replaced by value.
Although qName is the qualified name, the local name is used to decide if an existing attribute's value should be replaced.
Adds an attribute with the qualified name using the given qName, and the namespace URI nsURI with the value value. If an attribute with the same local name and namespace URI exists, the prefix is replaced by the prefix of qName and the value is replaced by value.
Although qName is the qualified name, the local name is used to decide if an existing attribute's value should be replaced.
void QDomElement::setTagName | ( | const QString & | name | ) |
Sets this element's tag name to name.
QString QDomElement::tagName | ( | ) | const |
Returns the tag name of this element. For an XML element like the following the tagname is "img".
QString QDomElement::text | ( | ) | const |
Returns the element's text or an empty string. Comments are ignored and it only evaluates QDomText and QDomCDATASection objects.
This method will return the following result.