Qyoto  4.0.5
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Properties
QtXml.QDomElement Class Reference

The QDomElement class represents one element in the DOM tree. More...

Inheritance diagram for QtXml.QDomElement:
Collaboration diagram for QtXml.QDomElement:

Public Member Functions

 QDomElement ()
 
 
 QDomElement (QDomElement x)
 
 
override void CreateProxy ()
 
new string Attribute (string name, string defValue="")
 
 
new string AttributeNS (string nsURI, string localName, string defValue="")
 
 
new QDomAttr AttributeNode (string name)
 
 
new QDomAttr AttributeNodeNS (string nsURI, string localName)
 
 
new QDomNamedNodeMap Attributes ()
 
 
new QDomNodeList ElementsByTagName (string tagname)
 
 
new QDomNodeList ElementsByTagNameNS (string nsURI, string localName)
 
 
new bool HasAttribute (string name)
 
 
new bool HasAttributeNS (string nsURI, string localName)
 
 
new QDomNode.NodeType nodeType ()
 
 
new void RemoveAttribute (string name)
 
 
new void RemoveAttributeNS (string nsURI, string localName)
 
 
new QDomAttr RemoveAttributeNode (QDomAttr oldAttr)
 
 
new void SetAttribute (string name, string value)
 
 
new void SetAttribute (string name, long value)
 
 
new void SetAttribute (string name, ulong value)
 
 
new void SetAttribute (string name, int value)
 
 
new void SetAttribute (string name, uint value)
 
 
new void SetAttribute (string name, float value)
 
 
new void SetAttribute (string name, double value)
 
 
new void SetAttributeNS (string nsURI, string qName, string value)
 
 
new void SetAttributeNS (string nsURI, string qName, int value)
 
 
new void SetAttributeNS (string nsURI, string qName, uint value)
 
 
new void SetAttributeNS (string nsURI, string qName, long value)
 
 
new void SetAttributeNS (string nsURI, string qName, ulong value)
 
 
new void SetAttributeNS (string nsURI, string qName, double value)
 
 
new QDomAttr SetAttributeNode (QDomAttr newAttr)
 
 
new QDomAttr SetAttributeNodeNS (QDomAttr newAttr)
 
 
new string Text ()
 
 
new void Dispose ()
 
- Public Member Functions inherited from QtXml.QDomNode
override bool Equals (object o)
 
override int GetHashCode ()
 
 QDomNode ()
 
 
 QDomNode (QDomNode arg1)
 
 
new QDomNode AppendChild (QDomNode newChild)
 
 
new QDomNamedNodeMap Attributes ()
 
 
new QDomNodeList ChildNodes ()
 
 
new void Clear ()
 
 
new QDomNode CloneNode (bool deep=true)
 
 
new int ColumnNumber ()
 
 
new QDomNode FirstChild ()
 
 
new QDomElement FirstChildElement (string tagName="")
 
 
new bool HasAttributes ()
 
 
new bool HasChildNodes ()
 
 
new QDomNode InsertAfter (QDomNode newChild, QDomNode refChild)
 
 
new QDomNode InsertBefore (QDomNode newChild, QDomNode refChild)
 
 
new bool IsAttr ()
 
 
new bool IsCDATASection ()
 
 
new bool IsCharacterData ()
 
 
new bool IsComment ()
 
 
new bool IsDocument ()
 
 
new bool IsDocumentFragment ()
 
 
new bool IsDocumentType ()
 
 
new bool IsElement ()
 
 
new bool IsEntity ()
 
 
new bool IsEntityReference ()
 
 
new bool IsNotation ()
 
 
new bool IsNull ()
 
 
new bool IsProcessingInstruction ()
 
 
new bool IsSupported (string feature, string version)
 
 
new bool IsText ()
 
 
new QDomNode LastChild ()
 
 
new QDomElement LastChildElement (string tagName="")
 
 
new int LineNumber ()
 
 
new string LocalName ()
 
 
new QDomNode NamedItem (string name)
 
 
new string NamespaceURI ()
 
 
new QDomNode NextSibling ()
 
 
new QDomElement NextSiblingElement (string taName="")
 
 
new string NodeName ()
 
 
new QDomNode.NodeType nodeType ()
 
 
new void Normalize ()
 
 
new QDomDocument OwnerDocument ()
 
 
new QDomNode ParentNode ()
 
 
new QDomNode PreviousSibling ()
 
 
new QDomElement PreviousSiblingElement (string tagName="")
 
 
new QDomNode RemoveChild (QDomNode oldChild)
 
 
new QDomNode ReplaceChild (QDomNode newChild, QDomNode oldChild)
 
 
new void Save (QTextStream arg1, int arg2)
 
 
new void Save (QTextStream arg1, int arg2, QDomNode.EncodingPolicy arg3)
 
 
new QDomAttr ToAttr ()
 
 
new QDomCDATASection ToCDATASection ()
 
 
new QDomCharacterData ToCharacterData ()
 
 
new QDomComment ToComment ()
 
 
new QDomDocument ToDocument ()
 
 
new QDomDocumentFragment ToDocumentFragment ()
 
 
new QDomDocumentType ToDocumentType ()
 
 
new QDomElement ToElement ()
 
 
new QDomEntity ToEntity ()
 
 
new QDomEntityReference ToEntityReference ()
 
 
new QDomNotation ToNotation ()
 
 
new QDomProcessingInstruction ToProcessingInstruction ()
 
 
new QDomText ToText ()
 
 
new void Dispose ()
 

Protected Member Functions

 QDomElement (System.Type dummy)
 
- Protected Member Functions inherited from QtXml.QDomNode
 QDomNode (System.Type dummy)
 

Properties

new string TagName [get, set]
 
 
- Properties inherited from QtXml.QDomNode
new string NodeValue [get, set]
 
 
new string Prefix [get, set]
 
 
virtual System.IntPtr SmokeObject [get, set]
 

Additional Inherited Members

- Public Types inherited from QtXml.QDomNode
enum  EncodingPolicy { EncodingFromDocument = 1, EncodingFromTextStream = 2 }
  More...
 
enum  NodeType {
  AttributeNode = 2, BaseNode = 21, CDATASectionNode = 4, CharacterDataNode = 22,
  CommentNode = 8, DocumentFragmentNode = 11, DocumentNode = 9, DocumentTypeNode = 10,
  ElementNode = 1, EntityNode = 6, EntityReferenceNode = 5, NotationNode = 12,
  ProcessingInstructionNode = 7, TextNode = 3
}
  More...
 
- Static Public Member Functions inherited from QtXml.QDomNode
static bool operator!= (QDomNode arg1, QDomNode arg2)
 
 
static bool operator== (QDomNode arg1, QDomNode arg2)
 
 
- Protected Attributes inherited from QtXml.QDomNode
SmokeInvocation interceptor
 

Detailed Description

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.

QDomElement e = //...

//...

QString s = e.text()

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.

QString text;

QDomElement element = doc.documentElement();

for(QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling())

{

QDomText t = n.toText();

if (!t.isNull())

text += t.data();

}

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 decendents 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:

QDomDocument doc = // ...

QDomElement root = doc.firstChildElement("database");

QDomElement elt = root.firstChildElement("entry");

for (; !elt.isNull(); elt = elt.nextSiblingElement("entry")) {

// ...

}

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.

Constructor & Destructor Documentation

QtXml.QDomElement.QDomElement ( System.Type  dummy)
protected
QtXml.QDomElement.QDomElement ( )

Constructs an empty element. Use the QDomDocument::createElement() function to construct elements with content.

QtXml.QDomElement.QDomElement ( QDomElement  x)

Constructs a copy of x.

The data of the copy is shared (shallow copy): modifying one node will also change the other. If you want to make a deep copy, use cloneNode().

Member Function Documentation

new string QtXml.QDomElement.Attribute ( string  name,
string  defValue = "" 
)

Returns the attribute called name. If the attribute does not exist defValue is returned.

See also setAttribute(), attributeNode(), setAttributeNode(), and attributeNS().

new QDomAttr QtXml.QDomElement.AttributeNode ( string  name)

Returns the QDomAttr object that corresponds to the attribute called name. If no such attribute exists a null attribute is returned.

See also setAttributeNode(), attribute(), setAttribute(), and attributeNodeNS().

new QDomAttr QtXml.QDomElement.AttributeNodeNS ( string  nsURI,
string  localName 
)

Returns the QDomAttr object that corresponds to the attribute with the local name localName and the namespace URI nsURI. If no such attribute exists a null attribute is returned.

See also setAttributeNodeNS(), setAttributeNode(), attribute(), and setAttribute().

new string QtXml.QDomElement.AttributeNS ( string  nsURI,
string  localName,
string  defValue = "" 
)

Returns the attribute with the local name localName and the namespace URI nsURI. If the attribute does not exist defValue is returned.

See also setAttributeNS(), attributeNodeNS(), setAttributeNodeNS(), and attribute().

new QDomNamedNodeMap QtXml.QDomElement.Attributes ( )

Returns a QDomNamedNodeMap containing all this element's attributes.

See also attribute(), setAttribute(), attributeNode(), and setAttributeNode().

override void QtXml.QDomElement.CreateProxy ( )
virtual

Reimplemented from QtXml.QDomNode.

new void QtXml.QDomElement.Dispose ( )
new QDomNodeList QtXml.QDomElement.ElementsByTagName ( string  tagname)

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.

See also elementsByTagNameNS() and QDomDocument::elementsByTagName().

new QDomNodeList QtXml.QDomElement.ElementsByTagNameNS ( string  nsURI,
string  localName 
)

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.

See also elementsByTagName() and QDomDocument::elementsByTagNameNS().

new bool QtXml.QDomElement.HasAttribute ( string  name)

Returns true if this element has an attribute called name; otherwise returns false.

Note: This function does not take the presence of namespaces into account. As a result, the specified name will be tested against fully-qualified attribute names that include any namespace prefixes that may be present.

Use hasAttributeNS() to explicitly test for attributes with specific namespaces and names.

new bool QtXml.QDomElement.HasAttributeNS ( string  nsURI,
string  localName 
)

Returns true if this element has an attribute with the local name localName and the namespace URI nsURI; otherwise returns false.

new QDomNode.NodeType QtXml.QDomElement.nodeType ( )

Returns ElementNode.

new void QtXml.QDomElement.RemoveAttribute ( string  name)

Removes the attribute called name name from this element.

See also setAttribute(), attribute(), and removeAttributeNS().

new QDomAttr QtXml.QDomElement.RemoveAttributeNode ( QDomAttr  oldAttr)

Removes the attribute oldAttr from the element and returns it.

See also attributeNode() and setAttributeNode().

new void QtXml.QDomElement.RemoveAttributeNS ( string  nsURI,
string  localName 
)

Removes the attribute with the local name localName and the namespace URI nsURI from this element.

See also setAttributeNS(), attributeNS(), and removeAttribute().

new void QtXml.QDomElement.SetAttribute ( string  name,
string  value 
)

Adds an attribute called name with value value. If an attribute with the same name exists, its value is replaced by value.

See also attribute(), setAttributeNode(), and setAttributeNS().

new void QtXml.QDomElement.SetAttribute ( string  name,
long  value 
)

Adds an attribute called name with value value. If an attribute with the same name exists, its value is replaced by value.

See also attribute(), setAttributeNode(), and setAttributeNS().

new void QtXml.QDomElement.SetAttribute ( string  name,
ulong  value 
)

Adds an attribute called name with value value. If an attribute with the same name exists, its value is replaced by value.

See also attribute(), setAttributeNode(), and setAttributeNS().

new void QtXml.QDomElement.SetAttribute ( string  name,
int  value 
)

This is an overloaded function.

The number is formatted according to the current locale.

new void QtXml.QDomElement.SetAttribute ( string  name,
uint  value 
)

Adds an attribute called name with value value. If an attribute with the same name exists, its value is replaced by value.

See also attribute(), setAttributeNode(), and setAttributeNS().

new void QtXml.QDomElement.SetAttribute ( string  name,
float  value 
)

This is an overloaded function.

The number is formatted according to the current locale.

new void QtXml.QDomElement.SetAttribute ( string  name,
double  value 
)

This is an overloaded function.

The number is formatted according to the current locale.

new QDomAttr QtXml.QDomElement.SetAttributeNode ( QDomAttr  newAttr)

Adds the attribute newAttr to this element.

If the element has another attribute that has the same name as newAttr, this function replaces that attribute and returns it; otherwise the function returns a null attribute.

See also attributeNode(), setAttribute(), and setAttributeNodeNS().

new QDomAttr QtXml.QDomElement.SetAttributeNodeNS ( QDomAttr  newAttr)

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 function replaces that attribute and returns it; otherwise the function returns a null attribute.

See also attributeNodeNS(), setAttributeNS(), and setAttributeNode().

new void QtXml.QDomElement.SetAttributeNS ( string  nsURI,
string  qName,
string  value 
)

Adds an attribute with the qualified name qName and the namespace URI nsURI with the value value. If an attribute with the same local name and namespace URI exists, its prefix is replaced by the prefix of qName and its value is repaced by value.

Although qName is the qualified name, the local name is used to decide if an existing attribute's value should be replaced.

See also attributeNS(), setAttributeNodeNS(), and setAttribute().

new void QtXml.QDomElement.SetAttributeNS ( string  nsURI,
string  qName,
int  value 
)

This is an overloaded function.

new void QtXml.QDomElement.SetAttributeNS ( string  nsURI,
string  qName,
uint  value 
)

Adds an attribute with the qualified name qName and the namespace URI nsURI with the value value. If an attribute with the same local name and namespace URI exists, its prefix is replaced by the prefix of qName and its value is repaced by value.

Although qName is the qualified name, the local name is used to decide if an existing attribute's value should be replaced.

See also attributeNS(), setAttributeNodeNS(), and setAttribute().

new void QtXml.QDomElement.SetAttributeNS ( string  nsURI,
string  qName,
long  value 
)

Adds an attribute with the qualified name qName and the namespace URI nsURI with the value value. If an attribute with the same local name and namespace URI exists, its prefix is replaced by the prefix of qName and its value is repaced by value.

Although qName is the qualified name, the local name is used to decide if an existing attribute's value should be replaced.

See also attributeNS(), setAttributeNodeNS(), and setAttribute().

new void QtXml.QDomElement.SetAttributeNS ( string  nsURI,
string  qName,
ulong  value 
)

Adds an attribute with the qualified name qName and the namespace URI nsURI with the value value. If an attribute with the same local name and namespace URI exists, its prefix is replaced by the prefix of qName and its value is repaced by value.

Although qName is the qualified name, the local name is used to decide if an existing attribute's value should be replaced.

See also attributeNS(), setAttributeNodeNS(), and setAttribute().

new void QtXml.QDomElement.SetAttributeNS ( string  nsURI,
string  qName,
double  value 
)

This is an overloaded function.

new string QtXml.QDomElement.Text ( )

Returns the element's text or an empty string.

Example:

<h1>Hello <b>Qt</b> <![CDATA[<xml is cool>]]></h1>

The function text() of the QDomElement for the <h1> tag, will return the following text:

Hello Qt <xml is cool>

Comments are ignored by this function. It only evaluates QDomText and QDomCDATASection objects.

Property Documentation

new string QtXml.QDomElement.TagName
getset

Returns the tag name of this element. For an XML element like this:

<img src="myimg.png">

the tagname would return "img".

Sets this element's tag name to name.