TXmlEngElement Class Reference

#include <xml/dom/xmlengelement.h>

Link against: xmlenginedom.lib

class TXmlEngElement : public TXmlEngNode

Inherits from

Public Member Functions
TXmlEngElement()
TXmlEngElement(void *)
IMPORT_C TXmlEngNamespaceAddNamespaceDeclarationL(const TDesC8 &, const TDesC8 &)
IMPORT_C TXmlEngAttrAddNewAttributeL(const TDesC8 &, const TDesC8 &)
IMPORT_C TXmlEngAttrAddNewAttributeL(const TDesC8 &, const TDesC8 &, const TXmlEngNamespace)
IMPORT_C TXmlEngAttrAddNewAttributeL(const TDesC8 &, const TDesC8 &, const TDesC8 &, const TDesC8 &)
TXmlEngAttr AddNewAttributeSameNsL(const TDesC8 &, const TDesC8 &)
IMPORT_C TXmlEngAttrAddNewAttributeUsePrefixL(const TDesC8 &, const TDesC8 &, const TDesC8 &)
IMPORT_C TXmlEngAttrAddNewAttributeWithNsL(const TDesC8 &, const TDesC8 &, const TDesC8 &)
IMPORT_C TXmlEngElementAddNewElementAutoPrefixL(const TDesC8 &, const TDesC8 &, TXmlEngElement)
IMPORT_C TXmlEngElementAddNewElementL(const TDesC8 &)
IMPORT_C TXmlEngElementAddNewElementL(const TDesC8 &, TXmlEngNamespace)
IMPORT_C TXmlEngElementAddNewElementL(const TDesC8 &, const TDesC8 &, const TDesC8 &)
IMPORT_C TXmlEngElementAddNewElementSameNsL(const TDesC8 &)
IMPORT_C TXmlEngElementAddNewElementUsePrefixL(const TDesC8 &, const TDesC8 &)
IMPORT_C TXmlEngElementAddNewElementWithNsL(const TDesC8 &, const TDesC8 &)
IMPORT_C voidAddTextL(const TDesC8 &)
IMPORT_C TXmlEngAttrAddXmlIdL(const TDesC8 &, const TDesC8 &, TXmlEngNamespace)
IMPORT_C voidAppendTextNoEncL(const TDesC8 &)
IMPORT_C TXmlEngAttrAttributeNodeL(const TDesC8 &, const TDesC8 &)
IMPORT_C TPtrC8AttributeValueL(const TDesC8 &, const TDesC8 &)
voidClearElement()
IMPORT_C voidCopyAttributesL(TXmlEngElement)
IMPORT_C voidCopyChildrenL(TXmlEngElement)
TXmlEngElement CopyL()
TXmlEngNamespace DefaultNamespaceL()
IMPORT_C TXmlEngElementElementCopyNoChildrenL(TBool)
IMPORT_C TXmlEngNamespaceFindOrCreateNsDeclL(const TDesC8 &, const TDesC8 &)
IMPORT_C TXmlEngNamespaceFindOrCreateNsDeclL(const TDesC8 &)
IMPORT_C voidGetAttributes(RXmlEngNodeList< TXmlEngAttr > &)
IMPORT_C voidGetChildElements(RXmlEngNodeList< TXmlEngElement > &)
IMPORT_C voidGetElementsByTagNameL(RXmlEngNodeList< TXmlEngElement > &, const TDesC8 &, const TDesC8 &)
TBool HasAttributeL(const TDesC8 &, const TDesC8 &)
IMPORT_C TBoolHasNsDeclarationForPrefixL(const TDesC8 &)
IMPORT_C TXmlEngNamespaceLookupNamespaceByPrefixL(const TDesC8 &)
IMPORT_C TXmlEngNamespaceLookupNamespaceByUriL(const TDesC8 &)
IMPORT_C voidRemoveAttributeL(const TDesC8 &, const TDesC8 &)
IMPORT_C voidRemoveAttributes()
IMPORT_C voidRemoveChildElementsL(const TDesC8 &, const TDesC8 &)
IMPORT_C voidRemoveChildren()
IMPORT_C voidRemoveNamespaceDeclarations()
IMPORT_C voidRenameElementL(const TDesC8 &, const TDesC8 &, const TDesC8 &)
IMPORT_C voidSetAttributeL(const TDesC8 &, const TDesC8 &, const TDesC8 &, const TDesC8 &)
IMPORT_C voidSetAttributeNodeL(TXmlEngAttr)
IMPORT_C TXmlEngNamespaceSetDefaultNamespaceL(const TDesC8 &)
IMPORT_C voidSetEscapedTextL(const TDesC8 &)
IMPORT_C voidSetNoDefaultNamespaceL()
IMPORT_C voidSetTextL(const TDesC8 &)
IMPORT_C voidSetTextNoEncL(const TDesC8 &)
IMPORT_C TPtrC8Text()
IMPORT_C TXmlEngNamespaceTheXMLNamespaceL()
Inherited Attributes
TXmlEngNode::iInternal
Inherited Enumerations
TXmlEngNode:TXmlEngDOMNodeType
Inherited Functions
TXmlEngNode::AddUserData(MXmlEngUserData *)
TXmlEngNode::AppendChildL(TXmlEngNode)
TXmlEngNode::AsAttr()const
TXmlEngNode::AsBinaryContainer()const
TXmlEngNode::AsCDATASection()const
TXmlEngNode::AsChunkContainer()const
TXmlEngNode::AsComment()const
TXmlEngNode::AsDataContainer()const
TXmlEngNode::AsDocumentFragment()const
TXmlEngNode::AsElement()const
TXmlEngNode::AsEntityReference()const
TXmlEngNode::AsFileContainer()const
TXmlEngNode::AsNamespace()const
TXmlEngNode::AsProcessingInstruction()const
TXmlEngNode::AsText()const
TXmlEngNode::BaseUriL(RBuf8 &)const
TXmlEngNode::CopyToL(TXmlEngNode)const
TXmlEngNode::DoUnlinkNode()
TXmlEngNode::FirstChild()const
TXmlEngNode::GetChildNodes(RXmlEngNodeList< TXmlEngNode > &)const
TXmlEngNode::HasAttributes()const
TXmlEngNode::HasChildNodes()const
TXmlEngNode::InnerXmlL(RBuf8 &)
TXmlEngNode::IsDefaultNamespaceL(const TDesC8 &)const
TXmlEngNode::IsNull()const
TXmlEngNode::IsSameNode(TXmlEngNode)const
TXmlEngNode::IsSimpleTextContents()const
TXmlEngNode::LastChild()const
TXmlEngNode::LinkBefore(TXmlEngNode)
TXmlEngNode::LookupNamespaceUriL(const TDesC8 &)const
TXmlEngNode::LookupPrefixL(const TDesC8 &)const
TXmlEngNode::MoveAfterSibling(TXmlEngNode)
TXmlEngNode::MoveBeforeSibling(TXmlEngNode)
TXmlEngNode::MoveTo(TXmlEngNode)
TXmlEngNode::MoveToL(TXmlEngNode)
TXmlEngNode::Name()const
TXmlEngNode::NamespaceDeclaration()const
TXmlEngNode::NamespaceUri()const
TXmlEngNode::NextSibling()const
TXmlEngNode::NodeType()const
TXmlEngNode::NotNull()const
TXmlEngNode::OuterXmlL(RBuf8 &)
TXmlEngNode::OwnerDocument()const
TXmlEngNode::ParentNode()const
TXmlEngNode::Prefix()const
TXmlEngNode::PreviousSibling()const
TXmlEngNode::ReconcileNamespacesL()
TXmlEngNode::Remove()
TXmlEngNode::RemoveUserData()
TXmlEngNode::ReplaceWith(TXmlEngNode)
TXmlEngNode::ReplaceWithL(TXmlEngNode)
TXmlEngNode::SetAsFirstSibling()
TXmlEngNode::SetAsLastSibling()
TXmlEngNode::SetValueL(const TDesC8 &)
TXmlEngNode::SubstituteForL(TXmlEngNode)
TXmlEngNode::TXmlEngNode()
TXmlEngNode::TXmlEngNode(void *)
TXmlEngNode::Unlink()
TXmlEngNode::UserData()const
TXmlEngNode::Value()const
TXmlEngNode::WholeTextContentsCopyL(RBuf8 &)const

Detailed Description

This class represents an XML element in the DOM tree.

Namespace handling:

The namespace of a XML element is an URI that in pair with the local part of the element's name consistute the expanded-name of the element. It is said that "the element is of NNN namespace".

XML elements are shown as belonging to a specific namespace by using prefixes that previously were bound to some namespace URIs. The scope of a prefix is the element, where it was declared and all its child (sub-)elements.

Namespace declaration is created by using a special xmlns:{prefix-name} attribute (which is not really considered as an attribute in DOM):
   <a xmlns:pr="http://some.uri.com/"> ... </a>
OR
   <pr:a xmlns:pr="http://some.uri.com/"> ... </a>
   <a xmlns="http://some.uri.com/"> ... </a>

The latter two examples are equivalent and show the use of default namespace.

Implementation notes:
  • Elements having no namespace are either presented with a NULL TXmlEngNamespace node or a TXmlEngNamespace node that has NULL (KNullDesC8) prefix and namespace URI set to "" (an empty descriptor). The former is used by default on all nodes, whereas the latter is for cases when some node contains undeclaration of the default namespace:
    	   <a xmlns=""> .. </a>
  • The prefix of the default attribute is NULL (KNullDesC8), not an "" (empty descriptor). An empty descriptor which corresponds to
          <a xmlns:="http://some.uri.com/"> ... </a>
    (it does not contradict XML spec, but you are strongly advised against using this)
  • Prefix "xml" is reserved by XML Namespace spec for special purposes; it is implicitly bound to XML's namespace "http://www.w3.org/XML/1998/namespace" and no one is allowed to use this prefix except as with spec-defined elements and attributes or to rebind this prefix to other namespaces

  • Namespace URI may be "" (an empty descriptor) only for default namespace. In other words, "" namespace URI may not be bound to non-NULL prefix.

Declaration of "" (an empty descriptor) namespace with NULL (KNullDesC8) prefix results in:
      <a xmlns=""> ... </a>
which undeclares any existing (in some parent element) default namespace for the scope of element 'a': element, its attributes and all child nodes of DOM tree. Note, that such "undeclaration" will be added only if neccessary.
  • Unneccessary namespace declaration are ignored. Attemps to add namespace binding using same namespace URI and prefix if such binding already exists in the scope will have no effect.

  • IMPORTANT! Attributes DO NOT HAVE default namespaces. If an attribute has no prefix, its namespace is undeclared even if there is some default namespaces for the scope of the element, which contains the attribute.

So, it is wrong to write something like this:
    <a xmlns="ns_uri"  attr="value"> ... </a>
and assume that the attr belongs to namespace pointed to with ns_uri.
HINTS:
  • Use namespace declaration nodes as much as possible (but watch out for prefix collisions).

  • Add most referred to namespace declarations (AddNamespaceDeclarationL(uri,pref)) after any other namespace declarations in a element -- they will be found faster in namespace lookups.

For more informarion on NULL and NULL nodes:

See also: TXmlEngNode KNullDesC8

Constructor & Destructor Documentation

TXmlEngElement ( )

TXmlEngElement()[inline]

Default constructor

TXmlEngElement ( void * )

TXmlEngElement(void *aInternal)[inline]

Constructor

ParameterDescription
aInternalelement pointer

Member Function Documentation

AddNamespaceDeclarationL ( const TDesC8 &, const TDesC8 & )

IMPORT_C TXmlEngNamespaceAddNamespaceDeclarationL(const TDesC8 &aNsUri,
const TDesC8 &aPrefix
)

Adds a namespace declaration to the current element: a binding of prefix to namespace URI.

If the same namespace declaration exists (same prefix and URI), a redundant namespace declaration will not be created.

Both KNullDesC8 or an empty descriptor may be used for "UNDEFINED URI" and "NO PREFIX" values of arguments. Please refer to the class documentation for more specific information.

See also: TXmlEngElement KNullDesC8

Note: Undeclaring of default namespace (xmlns="") is supported by the SetNoDefaultNamespace() method.

See also: SetNoDefaulNamespace()

Note: Adding a namespace declaration that rebinds the prefix mapping (or default namespace) used by nodes lower in the tree may damage the document tree because references to namespace declarations are not updated. However, after serialization, the document will have the desired structure. Use this method with care!

Copies are taken of descripters passed in.

leave
KXmlEngErrNullNode Element is NULL
leave
KXmlEngErrWrongUseOfAPI URI or prefix is not specified
leave
  • One of the system-wide error codes

ParameterDescription
aNsUriNamespace URI, KNullDesC8 or an empty descriptor.
aPrefixNamespace prefix, KNullDesC8 or an empty descriptor.

Returns: The namespace that was created or found or a NULL namespace if the namespace is being undeclared.

AddNewAttributeL ( const TDesC8 &, const TDesC8 & )

IMPORT_C TXmlEngAttrAddNewAttributeL(const TDesC8 &aName,
const TDesC8 &aValue
)

Creates a new attribute node outside of any namespace (i.e. it has no prefix), sets the attribute's value and links it as the last attribute of the current element.

Note:
  • No checks are made that an attribute with the same name exists. Use this method only on newly created elements! Otherwise, use TXmlEngElement::SetAttributeL()

Attributes do not inherit default namespace of its element (http://w3.org/TR/REC-xml-names/#defaulting)
When adding the first attribute, use TXmlEngNode::SetAsFirstSibling() on the attribute:
        TXmlEngElement el = ... ; // get some element
        el.AddNewAttributeL("version","0.1").SetAsFirstSibling();

Copies are taken of descripters passed in.

See also: SetAsLastSibling() MoveBeforeSibling(TXmlEngNode) MoveAfterSibling(TXmlEngNode)

leave
KXmlEngErrNullNode The node is NULL
leave
KXmlEngErrWrongUseOfAPI aName is empty
leave
  • One of the system-wide error codes

ParameterDescription
aNameA local name of the attribute
aValueValue to set for new attribute or KNullDesC8

Returns: The created attribute

AddNewAttributeL ( const TDesC8 &, const TDesC8 &, const TXmlEngNamespace )

IMPORT_C TXmlEngAttrAddNewAttributeL(const TDesC8 &aName,
const TDesC8 &aValue,
const TXmlEngNamespaceaNsDef
)

Creates a new attribute node and adds it to the element.

The provided namespace declaration is used to set the attribute's namespace.

Note: If aNsDef is not defined in some of the attribute's ascendants (including this element), then the ReconcileNamespacesL() method must be called on this element later.

Copies are taken of descripters passed in.

leave
KXmlEngErrNullNode The node is NULL
leave
KXmlEngErrWrongUseOfAPI aName is empty
leave
  • One of the system-wide error codes

ParameterDescription
aNameThe local name of attribute
aValueValue to set for new attribute or KNullDesC8
aNsDefNamespace to add to the attribute

Returns: The created attribute

AddNewAttributeL ( const TDesC8 &, const TDesC8 &, const TDesC8 &, const TDesC8 & )

IMPORT_C TXmlEngAttrAddNewAttributeL(const TDesC8 &aName,
const TDesC8 &aValue,
const TDesC8 &aNsUri,
const TDesC8 &aPrefix
)

Creates a new attribute for the element. A namespace declaration for the attribute namespace is also created.

Note: Namespace declarations are reused if possible (no redundant ones are created)

Copies are taken of descripters passed in.

leave
KXmlEngErrNullNode The node is NULL
leave
KXmlEngErrWrongUseOfAPI aName is empty
leave
  • One of the system-wide error codes

ParameterDescription
aNameThe local name of attribute
aValueValue to set for the new attribute or an empty string
aNsUriNamespace URI
aPrefixNamespace prefix

Returns: The created attribute

AddNewAttributeSameNsL ( const TDesC8 &, const TDesC8 & )

TXmlEngAttr AddNewAttributeSameNsL(const TDesC8 &aName,
const TDesC8 &aValue
)[inline]

Creates a new attribute node using the namespace of its parent element (this element), sets the attribute's value and links it as the last attribute of the element

For more hints how to use it

See also: AddNewAttributeL(const TDesC8&,const TDesC8&)

Note:
  • No checks are made that an attribute with the same name exists

  • if the namespace of the parent element is default (i.e. bound prefix is KNullDesC8), then a temporary prefix will be used and bound to the same namespace URI as the element (It is due to the fact that default namespaces do not spread on unprefixed attributes, see http://w3.org/TR/REC-xml-names/#defaulting)

Copies are taken of descripters passed in.

See also: KNullDesC8

leave
KXmlEngErrNullNode The node is NULL
leave
KXmlEngErrWrongUseOfAPI aName is empty
leave
  • One of the system-wide error codes

ParameterDescription
aNameLocal name of attribute
aValueValue to set for the new attribute or empty.

Returns: The created attribute

AddNewAttributeUsePrefixL ( const TDesC8 &, const TDesC8 &, const TDesC8 & )

IMPORT_C TXmlEngAttrAddNewAttributeUsePrefixL(const TDesC8 &aLocalName,
const TDesC8 &aValue,
const TDesC8 &aPrefix
)

Creates a new attribute using the namespace which is bound to the specified prefix

Use this mothod only for construction of new parts of DOM tree where you know for sure that the prefix is bound in the given scope.
        TXmlEngElement el = parent.AddNewAttributeUsePrefixL("property","ObjName","rdf");
        el.AddNewAttributeUsePrefixL("type", "xs:integer", "rdf");
Otherwise, you should check that the prefix is bound like this example shows:
        TXmlEngNamespace boundNS = TXmlEngNamespace::LookupByPrefix(thisElement, prefix);
        if (boundNS.NotNull()){
            thisElement.AddNewAttributeUsePrefixL("name", value, prefix);
        }

Note: Use AddNewAttributeNsL(name,value,nsDefNode) as much as you can, because it is the most efficient way to create namespaced DOM elements (no additional lookups for namespace declarations are required).

        // If namespace with given URI is not in the scope, then it will be declared
        // and bound to "data" prefix.
        TXmlEngNamespace nsDef = elem.FindOrCreateNsDefL("http://../Data", "data");
        elem.AddNewAttributeL("location", "...", nsDef);
        elem.AddNewElementL("child", nsDef).AddNewAttributeL("attr","...value...");
        // the result is
            ...
         <elem xmlns:data="http://../Data" data:location="...">
            <data:child attr="...value..."/>
         </elem>
            ...
        //

Copies are taken of descripters passed in.

leave
KXmlEngErrNullNode The node is NULL
leave
KXmlEngErrWrongUseOfAPI aLocalName is empty
leave
KErrNoMemory The namespace is not found and the URI is not http://www.w3.org/XML/1998/namespace; or there is a memory allocation error
leave
  • One of the system-wide error codes

ParameterDescription
aLocalNameThe local name of the attribute
aValueValue to set for the new attribute or empty string.
aPrefixNamespace prefix for the new attribute

Returns: The created attribute

AddNewAttributeWithNsL ( const TDesC8 &, const TDesC8 &, const TDesC8 & )

IMPORT_C TXmlEngAttrAddNewAttributeWithNsL(const TDesC8 &aLocalName,
const TDesC8 &aValue,
const TDesC8 &aNsUri
)

Creates new attributes using the namespace in scope, which has the specified URI

Almost the same as AddNewAttributeUsePrefixL() but does lookup by namespace URI

See also: AddNewAttributeUsePrefixL(const TDesC8&,const TDesC8&,const TDesC8&)

Copies are taken of descripters passed in.

See also: KNullDesC8

leave
KXmlEngErrNullNode The node is NULL
leave
KXmlEngErrWrongUseOfAPI aLocalName is empty
leave
  • One of the system-wide error codes

ParameterDescription
aLocalNameThe local name of the attribute
aValueValue to set for new attribute or empty string.
aNsUriNamespace URI for new attribute

Returns: NULL attribute if namespace declaration is not found OR newly added to the end of attribute list attribute of this element.

AddNewElementAutoPrefixL ( const TDesC8 &, const TDesC8 &, TXmlEngElement )

IMPORT_C TXmlEngElementAddNewElementAutoPrefixL(const TDesC8 &aLocalName,
const TDesC8 &aNsUri,
TXmlEngElementaNsDeclTarget
)

Creates a new child element. If there is no a prefix binding for the new element's namespace, a namespace decaration is created with a generated prefix at the specified element.

The location of the namespace declaration may be controlled with aNsDeclTarget:

        el.AddNewElementAutoPrefixL(tagName,uri,KNullDesC8); // declare on the new element
        el.AddNewElementAutoPrefixL(tagName,uri,el);   // declare on the parent element
        el.AddNewElementAutoPrefixL(tagName,uri,doc.DocumentElement()); // declare on the root element
       ...

Note: The farther namespace declaration up in the document tree, the longer the namespace declaration lookups take.

Copies are taken of descripters passed in.

leave
KXmlEngErrNullNode Element is NULL
leave
KXmlEngErrWrongUseOfAPI Name or URI is not specified
leave
  • One of the system-wide error codes

ParameterDescription
aLocalNameName of the element to create
aNsUriNamespace URI of the new element
aNsDeclTargetThe element where the namespace declaraton should be placed.

Returns: The created element

AddNewElementL ( const TDesC8 & )

IMPORT_C TXmlEngElementAddNewElementL(const TDesC8 &aName)

Adds a child element with no namespace. This results in adding an element with aName and no prefix.

This method is the best for creation of non-namespace based documents or document fragments, where no default namespace declared.

It may be used also as a method for adding elements from the default namespace, BUT namespace will be assigned ONLY after serialization of the current document and parsing it back into a DOM tree!! If you need the new element to inherit the default namespace use:

       ...
       TXmlEngNamespace defns = element.DefaultNamespace();
       TXmlEngElement newEl = element.AddNewElementL("Name",defns);
       ...

It is not recommended that you use an undefined namespace with libxml. If an undefined namespace for the element is truly required, then DO NOT USE this method if there is a default namespace in the scope!

See also: AddNamespaceDeclarationL

Copies are taken of descripters passed in.

leave
KXmlEngErrNullNode Element is NULL
leave
KXmlEngErrWrongUseOfAPI Name is not specified
leave
  • One of the system-wide error codes

ParameterDescription
aNameThe name of the element

Returns: The created element

AddNewElementL ( const TDesC8 &, TXmlEngNamespace )

IMPORT_C TXmlEngElementAddNewElementL(const TDesC8 &aLocalName,
TXmlEngNamespaceaNsDecl
)

Creates a new child element with the provided name and namespace declaration and adds it as the last child of its parent.

Copies are taken of descripters passed in.

leave
KXmlEngErrNullNode Element is NULL
leave
KXmlEngErrWrongUseOfAPI Name is not specified
leave
  • One of the system-wide error codes

ParameterDescription
aLocalNameThe name of the element
aNsDeclThe namespace declaration that must be retrieved from one of the ascendant nodes of the new elements (and its prefix should not be remapped to another namespace URI for the scope of the new element)

Returns: Created element node

AddNewElementL ( const TDesC8 &, const TDesC8 &, const TDesC8 & )

IMPORT_C TXmlEngElementAddNewElementL(const TDesC8 &aLocalName,
const TDesC8 &aNsUri,
const TDesC8 &aPrefix
)

Creates a new child element with provided the name, prefix and namespace URI and adds it as the last child of its parent.

The new namespace declaration will be attached to the parent (this) element and used as the namespace for newly created child element. If such a binding already exists (same prefix is bound to same URI), it will be reused. If the prefix is already bound to some other namespace URI, it will be rebound by the new namespace declaration node.

Copies are taken of descripters passed in.

leave
KXmlEngErrNullNode Element is NULL
leave
KXmlEngErrWrongUseOfAPI Name or URI or prefix is not specified
leave
  • One of the system-wide error codes

ParameterDescription
aLocalNameName of the element
aNsUriURI of the element's namespace
aPrefixPrefix of the element

Returns: The created element node

AddNewElementSameNsL ( const TDesC8 & )

IMPORT_C TXmlEngElementAddNewElementSameNsL(const TDesC8 &aLocalName)

Creates a child element with the same namespace (and prefix if present) as the parent element and adds it as the last child of its parent.

Copies are taken of descripters passed in.

leave
KXmlEngErrNullNode Element is NULL
leave
KXmlEngErrWrongUseOfAPI Name is not specified
leave
  • One of the system-wide error codes

ParameterDescription
aLocalNameThe element's name

Returns: The created element

AddNewElementUsePrefixL ( const TDesC8 &, const TDesC8 & )

IMPORT_C TXmlEngElementAddNewElementUsePrefixL(const TDesC8 &aLocalName,
const TDesC8 &aPrefix
)

Performs a lookup for the namespace declaration for the specified prefix and adds a new child element with the found namespace as the last child of its parent.

Pre-condition
The prefix is bound
Copies are taken of descripters passed in.
leave
KXmlEngErrNullNode Element is NULL
leave
KXmlEngErrWrongUseOfAPI Name is not specified
leave
KErrNoMemory The namespace is not found and the prefix is not "xml" (i.e http://www.w3.org/XML/1998/namespace); or there is a memory allocation error.
leave
  • One of the system-wide error codes

ParameterDescription
aLocalNameThe element's name
aPrefixThe prefix to use for the search

Returns: The created element

AddNewElementWithNsL ( const TDesC8 &, const TDesC8 & )

IMPORT_C TXmlEngElementAddNewElementWithNsL(const TDesC8 &aLocalName,
const TDesC8 &aNsUri
)

Performs a lookup for the namespace declaration for the specified namespace URI and adds a new child element with the found namespace. The new element is added as the last child of this element.

Copies are taken of descripters passed in.

Pre-condition
A namespace with the given URI has been declared
leave
KXmlEngErrNullNode Element is NULL
leave
KXmlEngErrWrongUseOfAPI Name is not specified
leave
KErrNoMemory The namespace is not found and the URI is not http://www.w3.org/XML/1998/namespace or there is a memory allocation error
leave
  • One of the system-wide error codes

ParameterDescription
aLocalNameThe element's name
aNsUriThe namespace of the element

Returns: The created element

AddTextL ( const TDesC8 & )

IMPORT_C voidAddTextL(const TDesC8 &aString)

Adds text as a child of the element to the end of the list of children.

Note: There may be several TXmlEngTextNode and TXmlEngEntityReference nodes added, depending on the aString value. For example, if the curernt node has text and attributes, a text node and attribute nodes will be added.

Copies are taken of descripters passed in.

leave
KXmlEngErrNullNode Element is NULL
leave
  • One of the system-wide error codes

ParameterDescription
aStringText to be added as the element's content.

AddXmlIdL ( const TDesC8 &, const TDesC8 &, TXmlEngNamespace )

IMPORT_C TXmlEngAttrAddXmlIdL(const TDesC8 &aLocalName,
const TDesC8 &aValue,
TXmlEngNamespaceaNs =  TXmlEngNamespace()
)

Adds attribute to element that will be used as Xml:Id. Does not check if an attribute with the same name exists.

Note: Call RXmlEngDocument.RegisterXmlIdL(aName,aNsUri) first to register existed id's in the document. If the ids are not registered the ID will not be added to the element.

Copies are taken of descripters passed in.

leave
KXmlEngErrWrongUseOfAPI Element is NULL or attribute doesn't exist
leave
  • One of the system-wide error codes

ParameterDescription
aLocalNameName of the attribute
aValueValue of the attribute
aNsNamespace of the attribute

Returns: Attribute if created. Null attribute if Xml:Id exists

AppendTextNoEncL ( const TDesC8 & )

IMPORT_C voidAppendTextNoEncL(const TDesC8 &aNotEncString)

Appends a new text node with the value exactly as presented in the string. Predefined entities are not converted into the characters they represent. Existing child nodes are not removed.

See also: TXmlEngAttr::SetValueNoEncL(const TDesC8& aNewValue);

Copies are taken of descripters passed in.

leave
KXmlEngErrNullNode Element is NULL
leave
  • One of the system-wide error codes

ParameterDescription
aNotEncStringAppended string value

AttributeNodeL ( const TDesC8 &, const TDesC8 & )

IMPORT_C TXmlEngAttrAttributeNodeL(const TDesC8 &aLocalName,
const TDesC8 &aNamespaceUri = KNullDesC8
)const

Retrieves an attribute node with a specific namespace by its name.

See also: KNullDesC8

leave
  • One of the system-wide error codes

ParameterDescription
aLocalNameName of the attribute
aNamespaceUriAttribute namespace URI, default is KNullDesC8

Returns: Attribute node with matching namespace URI and name, NULL if not found.

AttributeValueL ( const TDesC8 &, const TDesC8 & )

IMPORT_C TPtrC8AttributeValueL(const TDesC8 &aLocalName,
const TDesC8 &aNamespaceUri =  KNullDesC8
)const

Returns the value of the attribute with the given name and namespace URI.

leave
  • One of the system-wide error codes

ParameterDescription
aLocalNameLocal name of the attribute
aNamespaceUriNamespace URI of the attribute, or the default namespace if not specified.

Returns: The attribute value (for as long as the attribute exists) or NULL if not found.

ClearElement ( )

voidClearElement()[inline]

Removes all element contents: child nodes, attributes and namespace declarations

See also: RemoveChildren() RemoveAttributes() RemoveNamespaceDeclarations();

CopyAttributesL ( TXmlEngElement )

IMPORT_C voidCopyAttributesL(TXmlEngElementaSrc)

Copies attributes from another element. It may be a very convenient method for initializing element with a set of predefined attributes.

Note: Namespaces of the this element may need to be reconciled if the copied attributes belong to any namespace that is not declared on some ascendant of this node.

See also: ReconcileNamespacesL()

leave
KXmlEngErrNullNode The element is NULL
leave
  • One of the system-wide error codes

ParameterDescription
aSrcSource element

CopyChildrenL ( TXmlEngElement )

IMPORT_C voidCopyChildrenL(TXmlEngElementaSrc)

Recursively copies the children (and all of it's associated information) from another element. Elements are appended to the current element's children list.

Note: Namespaces of this element may need to be reconciled after copy operation

See also: ReconcileNamespacesL()

leave
KXmlEngErrNullNode The element is NULL
leave
KXmlEngWrongUseOfAPI The source element is NULL
leave
  • One of the system-wide error codes

ParameterDescription
aSrcSource element

CopyL ( )

TXmlEngElement CopyL()const [inline]

Reimplemented from TXmlEngNode::CopyL()const

Specialized version of TXmlEngNode::CopyL()
leave
KXmlEngErrNullNode The element is NULL
leave
  • One of the system-wide error codes

Returns: Deep copy of the element.

DefaultNamespaceL ( )

TXmlEngNamespace DefaultNamespaceL()const [inline]

Get the default namespace for the element.

A NULL TXmlEngNamespace means that an element with no prefix has no namespace associated with it because no default namespace was declared or the default namespace was undeclared with xmlns=""

This function is equivalent to LookupNamespaceByPrefixL(KNullDesC8).

See also: KNullDesC8

leave
  • One of the system-wide error codes

Returns: The default namespace in the scope of the element

ElementCopyNoChildrenL ( TBool )

IMPORT_C TXmlEngElementElementCopyNoChildrenL(TBoolpreserveNsContext)const

Copies the element with its attributes, but not child nodes

If the context is preserved (preserveNsContent), then all namespace declarations that are in the element are writen to the <element ...> tag.

leave
KXmlEngErrNullNode The element is NULL
leave
  • One of the system-wide error codes

ParameterDescription
preserveNsContextWhether the namespace context should be preserved

Returns: The copied element

FindOrCreateNsDeclL ( const TDesC8 &, const TDesC8 & )

IMPORT_C TXmlEngNamespaceFindOrCreateNsDeclL(const TDesC8 &aNsUri,
const TDesC8 &aPrefix
)

Performs a search for the namespace in the scope of the element. This method will create new namespace declaration on the element if such namespace is not found.

Note: Be sure not to use the result of this method for non-descendants of the element or in situations when prefix overlapping might occur.

See also: TXmlEngAttr TXmlEngNamespace Please read the documentation for this class: TXmlEngElement

Copies are taken of descripters passed in.

leave
KXmlEngErrNullNode Element is NULL
leave
KXmlEngErrWrongUseOfAPI URI is not specified
leave
  • One of the system-wide error codes

See also: LookupNamespacebyUriL

ParameterDescription
aNsUriNamespace to search for
aPrefixPrefix to use for the new namespace declaration (if it is to be created)

Returns: The namespace found or created

FindOrCreateNsDeclL ( const TDesC8 & )

IMPORT_C TXmlEngNamespaceFindOrCreateNsDeclL(const TDesC8 &aNsUri)

Performs a search on the element and its ascendants for any namespace declaration with a given URI. Creates a new namespace declaration with a (unique) prefix if the search was not successful.

See also: AddNamespaceDeclarationL

Copies are taken of descripters passed in.

leave
KXmlEngErrNullNode Element is NULL
leave
KXmlEngErrWrongUseOfAPI URI is not specified
leave
  • One of the system-wide error codes

ParameterDescription
aNsUriNamespace to search for

Returns: The namespace found or created

GetAttributes ( RXmlEngNodeList< TXmlEngAttr > & )

IMPORT_C voidGetAttributes(RXmlEngNodeList< TXmlEngAttr > &aList)const

Retrieves a list of the attribute nodes of an element

Upon return, aList is initialized and is ready for use with HasNext() and Next() methods:

          ...
          TXmlEngElement root = doc.DocumentElement();
          RXmlEngNodeList<TXmlEngAttr>    attlist;
          root.GetAttributes(attlist);
          while (attlist.HasNext())
              processAttribute(attlist.Next());
          ...
	      attlist.Close();

If there are no attributes the list will be empty.

ParameterDescription
aListAn attribute list to initialize

GetChildElements ( RXmlEngNodeList< TXmlEngElement > & )

IMPORT_C voidGetChildElements(RXmlEngNodeList< TXmlEngElement > &aList)const

Retrieves a list of child elements of an element.

Upon return, aList is initialized and is ready for use with HasNext() and Next() methods.

Note: This returns a list of the child element nodes only.

There is no affect if the element attributes are empty.

ParameterDescription
aListA child list to initialize

GetElementsByTagNameL ( RXmlEngNodeList< TXmlEngElement > &, const TDesC8 &, const TDesC8 & )

IMPORT_C voidGetElementsByTagNameL(RXmlEngNodeList< TXmlEngElement > &aList,
const TDesC8 &aLocalName,
const TDesC8 &aNamespaceUri = KNullDesC8
)const

Initializes list of child elements with matching names and namespace URIs.

Note: This method does not list all descendants of the element, only child elements

See also: KNullDesC8

leave
  • One of the system-wide error codes

ParameterDescription
aListNode list to be created
aLocalNameElement name
aNamespaceUriif specified it sets the Namespace URI, default is KNullDesC8 (no namespace set).

HasAttributeL ( const TDesC8 &, const TDesC8 & )

TBool HasAttributeL(const TDesC8 &aLocalName,
const TDesC8 &aNamespaceUri = KNullDesC8
)const [inline]

Check if the element has an attribute with given parameters.

This function is the same as AttributeNodeL(uri,name).NotNull().

See also: KNullDesC8

leave
  • One of the system-wide error codes

ParameterDescription
aLocalNameName of attribute
aNamespaceUriNamespace uri, default is KNullDesC8.

Returns: ETrue if the element holds an attribute with such namespace URI and name.

HasNsDeclarationForPrefixL ( const TDesC8 & )

IMPORT_C TBoolHasNsDeclarationForPrefixL(const TDesC8 &aPrefix)const

Checks whether a prefix has been bound in this element (not in one of its ascendants)

Use this method for preventing prefix-name collision in a element node

Copies are taken of descripters passed in.

leave
  • One of the system-wide error codes

ParameterDescription
aPrefixNamespace prefix

Returns: ETrue if there is already a namespace declaration that uses aPrefix on this element

LookupNamespaceByPrefixL ( const TDesC8 & )

IMPORT_C TXmlEngNamespaceLookupNamespaceByPrefixL(const TDesC8 &aPrefix)const

Finds the namespace declaration that has a specific prefix in the list of parents for this element.

If no prefix is specified (an empty descriptor or KNullDesC8) then it is considered to be a "NO PREFIX" search. Therefore, if the namespace declaration for "no prefix" is searched, then the default namespace is returned.

Copies are taken of descripters passed in.

See also: KNullDesC8

leave
  • One of the system-wide error codes

ParameterDescription
aPrefixNamespace prefix.

Returns: The namespace, which may be NULL if prefix is not found; NULL result for "no prefix" means that default namespace is undefined.

LookupNamespaceByUriL ( const TDesC8 & )

IMPORT_C TXmlEngNamespaceLookupNamespaceByUriL(const TDesC8 &aUri)const

Finds a namespace declaration that has a specific namespace URI in the scope for the given node.

KNullDesC8 value of aUri is equivalent to an empty descriptor and means "UNDEFINED NAMESPACE". For such URI's a NULL namespace handle is always returned even if there is a namespace undeclaration, which has an empty descriptor URI (and KNullDesC8 prefix).

Hint: Use the returned instance of TXmlEngNamespace as the aNsDef argument to an element's methods that create new child elements and attributes. The same TXmlEngNamespace may be used on deeper descentants of the reference element (and doing this way will generally increase performance of DOM tree construction). However, if namespace bindings are not controlled for the element's children and the prefix (which is bound to the search namespace) is rebound to some other namespace URI, then reusing the namespace may lead to unwanted result.

Note: At the moment it is possible to retrieve namespace declaration nodes whose prefixes were rebound. Be careful when using returned TXmlEngNamespace objects for creation of new elements.

Copies are taken of descripters passed in.

leave
  • One of the system-wide error codes

ParameterDescription
aUriNamespace URI, for which the namespace declaration is searched

Returns: The namespace declaration that binds the given namespace URI to a prefix or sets it as a default namespace

RemoveAttributeL ( const TDesC8 &, const TDesC8 & )

IMPORT_C voidRemoveAttributeL(const TDesC8 &aLocalName,
const TDesC8 &aNamespaceUri = KNullDesC8
)

Removes the attribute with the given name and namespace URI (if it exists). Memory allocated for the attribute is freed.

See also: KNullDesC8

leave
  • One of the system-wide error codes

ParameterDescription
aLocalNameName of the attribute
aNamespaceUriAttribute namespace URI, default is KNullDesC8

RemoveAttributes ( )

IMPORT_C voidRemoveAttributes()

Resets element's attributes

RemoveChildElementsL ( const TDesC8 &, const TDesC8 & )

IMPORT_C voidRemoveChildElementsL(const TDesC8 &aLocalName,
const TDesC8 &aNamespaceUri
)

Removes the child element with the given name and namespace URI (if it exists). Memory allocated for the element is freed.

leave
KXmlEngErrNullNode The element is NULL
leave
  • One of the system-wide error codes

ParameterDescription
aLocalNameChild element name
aNamespaceUriChild element namespace

RemoveChildren ( )

IMPORT_C voidRemoveChildren()

Resets element's content: all child nodes are removed

RemoveNamespaceDeclarations ( )

IMPORT_C voidRemoveNamespaceDeclarations()

Resets all namespace declarations made in the element

Note: There can be references to these namespace declarations elsewhere! Use ReconcileNamespacesL() to fix that.

RenameElementL ( const TDesC8 &, const TDesC8 &, const TDesC8 & )

IMPORT_C voidRenameElementL(const TDesC8 &aLocalName,
const TDesC8 &aNamespaceUri,
const TDesC8 &aPrefix
)

Renames the element with the given name, namespace URI, and namespace prefix.

leave
  • One of the system-wide error codes

ParameterDescription
aLocalNameThe new element name
aNamespaceUriThe new namespace URI
aPrefixThe new namespace prefix

SetAttributeL ( const TDesC8 &, const TDesC8 &, const TDesC8 &, const TDesC8 & )

IMPORT_C voidSetAttributeL(const TDesC8 &aLocalName,
const TDesC8 &aValue,
const TDesC8 &aNamespaceUri = KNullDesC8,
const TDesC8 &aPrefix = KNullDesC8
)

Sets the value of the given attribute. The attribute is created if there is no such attribute yet.

Note: If prefix is not KNullDesC8 (or an empty descriptor), then the namespace URI may not be empty see http://www.w3.org/TR/REC-xml-names/#ns-decl (Definition #3)

Copies are taken of descripters passed in.

See also: KNullDesC8

leave
KXmlEngErrNullNode The element is NULL
leave
KXmlEngErrWrongUseOfAPI Attribute name not specified
leave
  • One of the system-wide error codes

ParameterDescription
aLocalNameAttribute name
aValueAttribute value
aNamespaceUriNamespace URI - default is KNullDesC8
aPrefixNamespace prefix - default is KNullDesC8

SetAttributeNodeL ( TXmlEngAttr )

IMPORT_C voidSetAttributeNodeL(TXmlEngAttraNewAttr)

Adds an attribute to this element. If an attribute of the same name exists, it will be destroyed.

leave
KXmlEngErrNullNode The element or attribute is NULL
leave
  • One of the system-wide error codes

ParameterDescription
aNewAttrThe new attribute

SetDefaultNamespaceL ( const TDesC8 & )

IMPORT_C TXmlEngNamespaceSetDefaultNamespaceL(const TDesC8 &aNsUri)

Adds a default namespace declaration.

1 This achieves the same result as with AddNamespaceDeclarationL(aNsUri, KNullDesC8), but additionally the element's namespace is modified (if it has no prefix and there were no default namespace declaration in the scope) to the new default one.

Copies are taken of descripters passed in.

See also: KNullDesC8

leave
KXmlEngErrNullNode Element is NULL
leave
KXmlEngErrWrongUseOfAPI URI is not specified
leave
  • One of the system-wide error codes

ParameterDescription
aNsUriNamespace URI; KNullDesC8 and empty descriptor are allowed to represent UNDEFINED NAMSPACE

Returns: The created namespace declaration (NULL for UNDEFINED NAMESPACE)

SetEscapedTextL ( const TDesC8 & )

IMPORT_C voidSetEscapedTextL(const TDesC8 &aEscapedString)

Sets the text content of the element from an escaped string.

See also: TXmlEngAttr::SetEscapedValueL(TDesC8&)

leave
KXmlEngErrNullNode Element is NULL
leave
  • One of the system-wide error codes

ParameterDescription
aEscapedStringNew value

SetNoDefaultNamespaceL ( )

IMPORT_C voidSetNoDefaultNamespaceL()

Undeclares any default namespace for this element and its descendants.

If there is already a default namespace, a xmlns="" namespace declaration is added. Otherwise, nothing happens, since elements with no prefix in such scope are automaticaly considered outside of any namespace.

The side effect of this method is that the namespace of the current element may change from the previous default namespace to a NULL TXmlEngNamespace, which is considered an absence of namespace.

If the element has a prefix (i.e. not having default namespace), then the only effect for the element is undeclaration of existing default namespace.

If the element is in the scope of another xmlns="" undeclaration, no action is taken.

Note: Use AddNamespaceDeclarationL(KNullDesC8,KNullDesC8) to force the creation of a xmlns="" declaration within the scope of another such declaration (otherwise unneccessary/duplicate declarations are not created).

Note: This method should be called on elements before adding children, because default namespace undeclaration is not spread into its subtree and descendants' default namespaces are not reset to NULL. This should be taken into account if later some processing on the subtree occurs. However, after serialization and deserialization, undeclared default namespace will affect whole element's subtree correctly.

See also: KNullDesC8

leave
KXmlEngErrNullNode Element is NULL
leave
  • One of the system-wide error codes

SetTextL ( const TDesC8 & )

IMPORT_C voidSetTextL(const TDesC8 &aString)

Sets text contents for the element. Any child nodes are removed. This function is the same as TXmlEngNode::SetValueL(TDesC8&)

See also: TXmlEngNode::SetValueL(TDesC8&)

leave
KXmlEngErrNullNode Element is NULL
leave
  • One of the system-wide error codes

ParameterDescription
aStringText to be set as element's content.

SetTextNoEncL ( const TDesC8 & )

IMPORT_C voidSetTextNoEncL(const TDesC8 &aNotEncString)

Sets the new element value exactly as presented in the string. Predefined entities are not converted into the characters they represent. Any child nodes are removed.

See also: TXmlEngAttr::SetValueNoEncL(const TDesC8& aNewValue);

leave
KXmlEngErrNullNode Element is NULL
leave
  • One of the system-wide error codes

ParameterDescription
aNotEncStringNew string value

Text ( )

IMPORT_C TPtrC8Text()const

Gets element content. This method may be used in most cases when the element has only simple text content (without entity references embedded). If the element's contents is mixed (other types of nodes present), only the contents of the first child node is returned (if it is a TXmlEngTextNode node).

For getting the contents of an element that has contents containing entity references, WholeTextValueCopyL() should be used.

See also: TXmlEngNode::WholeTextContentsCopyL()

Returns: The simple text contents of the element or NULL if there is no text.

TheXMLNamespaceL ( )

IMPORT_C TXmlEngNamespaceTheXMLNamespaceL()const

Retrieves the implicitly declared XML infoset binding of the 'xml' prefix to XML's namespace URI: "http://www.w3.org/XML/1998/namespace"

The result should be used for creating attributes beloging to the XML namespace (xml:lang, xml:space, xml:id , etc.)

DO NOT USE the methods LookupNamespaceByUriL(const TDesC8&) and LookupNamespaceByPrefixL(const TDesC8&) (with the arguments "http://www.w3.org/XML/1998/namespace" and "xml" respectively) for retrieving the namespace node, since in the case of a memory allocation fault, a NULL result is returned (and breaks your program silently)

Note: Normally the 'xml' prefix is bound to the XML namespace URI in the document node, BUT if this element is not a part of the document tree yet, the requested namespace declaration WILL BE ADDED to the current node. This is the reason why the method may fail in OOM conditions.

leave
KErrNoMemory The element is NULL or there was a memory allocation error
leave
  • One of the system-wide error codes

Returns: The namespace matching the prefix binding {xml,"http://www.w3.org/XML/1998/namespace"} in the current document