Link against: xmlengineDOM.lib
#include <xmlengnode.h>
Inherited by RXmlEngDocument, TXmlEngAttr, TXmlEngCharacterData, TXmlEngDataContainer, TXmlEngDocumentFragment, TXmlEngElement, TXmlEngEntityReference, TXmlEngNamespace, and TXmlEngProcessingInstruction.
Class implements methods that are similar for all XML node types i.e. element, attribute.
Sample code for node tree modifications:
RXmlEngDOMImplementation domImpl; domImpl.OpenL(); RXmlEngDocument iDoc; TXmlEngNode tmp = iDoc.DocumentElement(); TXmlEngNode tmp2 = tmp.FirstChild().CopyL(); tmp.AppendChildL(tmp2); tmp.FirstChild().NextSibling().CopyToL(tmp.LastChild()); tmp.LastChild().PreviousSibling().ReplaceWith(tmp.FirstChild().NextSibling()); tmp.FirstChild().MoveTo(tmp.FirstChild().NextSibling()); iDoc.Close(); domImpl.Close();
Public Types | |
enum | TXmlEngDOMNodeType { EElement = 1, EAttribute = 2, EText = 3, ECDATASection = 4, EEntityReference = 5, EEntity = 6, EProcessingInstruction = 7, EComment = 8, EDocument = 9, EDocumentType = 10, EDocumentFragment = 11, ENotation = 12, ENamespaceDeclaration = 18, EBinaryContainer = 30, EChunkContainer = 31, EFileContainer = 32 } |
The different element types carried by an XML tree. More... | |
Public Member Functions | |
TXmlEngNode () | |
Default constructor. | |
TXmlEngNode (void *aInternal) | |
Constructor. | |
TBool | IsNull () const |
Check if node is NULL. | |
TBool | NotNull () const |
Check if node is NULL. | |
TXmlEngAttr & | AsAttr () const |
Cast node to attribute node. | |
TXmlEngTextNode & | AsText () const |
Cast node to text node. | |
TXmlEngBinaryContainer & | AsBinaryContainer () const |
Cast node to binary data container. | |
TXmlEngChunkContainer & | AsChunkContainer () const |
Cast node to memory chunk container. | |
TXmlEngFileContainer & | AsFileContainer () const |
Cast node to file container. | |
TXmlEngDataContainer & | AsDataContainer () const |
Cast node to memory chunk container. | |
TXmlEngElement & | AsElement () const |
Cast node to element node. | |
TXmlEngComment & | AsComment () const |
Cast node to comment node. | |
TXmlEngNamespace & | AsNamespace () const |
Cast node to namespace node. | |
TXmlEngCDATASection & | AsCDATASection () const |
Cast node to CDATA section node. | |
TXmlEngEntityReference & | AsEntityReference () const |
Cast node to entity reference node. | |
TXmlEngProcessingInstruction & | AsProcessingInstruction () const |
Cast node to processing instruction node. | |
IMPORT_C TInt | InnerXmlL (RBuf8 &aBuffer) |
Get innerXML string. | |
IMPORT_C TInt | OuterXmlL (RBuf8 &aBuffer) |
Get outerXML string. | |
IMPORT_C void | SetAsFirstSibling () |
Moves the node to become the first in the list of its siblings Node is expected to have a parent. | |
IMPORT_C void | SetAsLastSibling () |
Moves the node to become the last in the list of its siblings Node is expected to have a parent. | |
IMPORT_C void | MoveBeforeSibling (TXmlEngNode aSiblingNode) |
Moves the node in the list of sibling nodes before another node Node is expected to have a parent. | |
IMPORT_C void | MoveAfterSibling (TXmlEngNode aSiblingNode) |
Moves the node in the list of sibling nodes after another node Node is expected to have a parent. | |
TXmlEngNode | MoveTo (TXmlEngNode aParent) |
Moves the node to another part of the tree or another document The node is unliked from current postion (if any) and appended to the its new parent. | |
IMPORT_C TXmlEngNode | Unlink () |
Detaches a node from document tree. | |
IMPORT_C void | ReconcileNamespacesL () |
Ensures that namespaces referred to in the node and its descendants are in the scope the node. | |
IMPORT_C void | Remove () |
Unlinks the node and destroys it; all child nodes are destroyed as well and all memory is freed. | |
IMPORT_C void | ReplaceWith (TXmlEngNode aNode) |
Current node is replaced with another node (subtree). | |
IMPORT_C TXmlEngNode | SubstituteForL (TXmlEngNode aNode) |
Another node is put instead of the current node. | |
IMPORT_C TXmlEngNamespace | NamespaceDeclaration () const |
Retrieves a "handle" for namespace declaration that applies to the node's namespace Note: DOM specs do not consider namespace declarations as a kind of nodes This API adds TXmlEngNamespace type of nodes, which is derived from TXmlEngNode. | |
IMPORT_C TBool | AddUserData (MXmlEngUserData *aData) |
Attaches a user data object to this node. | |
IMPORT_C MXmlEngUserData * | UserData () const |
Returns the user data object attached to this node. | |
IMPORT_C MXmlEngUserData * | RemoveUserData () |
Removes the user data onject attached to this node. | |
IMPORT_C TXmlEngNode | CopyL () const |
Clones the node completely: all attributes and namespace declarations (for TXmlEngElement nodes), values and children nodes are copied as well. | |
IMPORT_C TXmlEngNode | CopyToL (TXmlEngNode aParent) const |
Creates a deep copy of the node and appends the subtree as a new child to the provided parent node. | |
IMPORT_C TXmlEngNode | AppendChildL (TXmlEngNode aNewChild) |
Append a child node. | |
IMPORT_C void | GetChildNodes (RXmlEngNodeList< TXmlEngNode > &aList) const |
Initializes a node list with all children of the node. | |
IMPORT_C TXmlEngNode | ParentNode () const |
Get parent node of current node. | |
IMPORT_C TXmlEngNode | FirstChild () const |
Get first child of current node. | |
IMPORT_C TXmlEngNode | LastChild () const |
Get last child of current node. | |
IMPORT_C TXmlEngNode | PreviousSibling () const |
Get previous node of current node. | |
IMPORT_C TXmlEngNode | NextSibling () const |
Get fallowing node of current node. | |
IMPORT_C RXmlEngDocument | OwnerDocument () const |
Get document handle. | |
IMPORT_C TPtrC8 | Value () const |
Fetches value of this node, depending on its type. | |
IMPORT_C void | WholeTextContentsCopyL (RBuf8 &aOutput) const |
Get copy of node's text content What is returned depends on the node type. | |
IMPORT_C void | SetValueL (const TDesC8 &aValue) |
Sets value of this node. | |
IMPORT_C TBool | IsSimpleTextContents () const |
Check if node content is "simple text". | |
IMPORT_C TXmlEngDOMNodeType | NodeType () const |
Use NodeType() to find out the type of the node prior to casting object of TXmlEngNode class to one of its derived subclasses (TXmlEngElement, TXmlEngAttr, TXmlEngTextNode, etc. | |
IMPORT_C TPtrC8 | Name () const |
Get node name. | |
IMPORT_C TBool | HasChildNodes () const |
Check if node has child nodes. | |
IMPORT_C TBool | HasAttributes () const |
Check if node has attributes. | |
IMPORT_C void | BaseUriL (RBuf8 &aBaseUri) const |
Evaluates active base URI for the node by processing xml:base attributes of parents. | |
TBool | IsSameNode (TXmlEngNode aOther) const |
Compares nodes. | |
IMPORT_C TPtrC8 | NamespaceUri () const |
Get namespace uri. | |
IMPORT_C TPtrC8 | Prefix () const |
Get namespace prefix. | |
IMPORT_C TBool | IsDefaultNamespaceL (const TDesC8 &aNamespaceUri) const |
Check if nemespace is default for this node. | |
IMPORT_C TPtrC8 | LookupPrefixL (const TDesC8 &aNamespaceUri) const |
Searches the prefix that is bound to the given aNamespaceUri and applicable in the scope of this TXmlEngNode. | |
IMPORT_C TPtrC8 | LookupNamespaceUriL (const TDesC8 &aPrefix) const |
Searches the namespace URI that is bound to the given prefix. | |
Protected Member Functions | |
void | DoUnlinkNode () |
Unlinks the internal libxml2's node from double-linked list. | |
void | LinkBefore (TXmlEngNode aNode) |
Inserts the node in a double-linked list of nodes before specified node. | |
Protected Attributes | |
void * | iInternal |
Node pointer. |
|
The different element types carried by an XML tree.
|
|
Default constructor.
|
|
Constructor.
|
|
Attaches a user data object to this node. The ownership of the object is transferred. When the (underlying) node is deleted the Destroy method of the MXmlEngUserData class will be called. If there already is a user data object associated with this node, it will be deleted before attaching the new object.
|
|
Append a child node. This is universal operation for any types of nodes. Note, that some types of nodes cannot have children and some types of nodes are not allowed to be children of some other types.
|
|
Cast node to attribute node.
|
|
Cast node to binary data container.
|
|
Cast node to CDATA section node.
|
|
Cast node to memory chunk container.
|
|
Cast node to comment node.
|
|
Cast node to memory chunk container.
|
|
Cast node to element node.
|
|
Cast node to entity reference node.
|
|
Cast node to file container.
|
|
Cast node to namespace node.
|
|
Cast node to processing instruction node.
|
|
Cast node to text node.
|
|
Evaluates active base URI for the node by processing xml:base attributes of parents.
|
|
Clones the node completely: all attributes and namespace declarations (for TXmlEngElement nodes), values and children nodes are copied as well. Document nodes cannot be copied with this method: RXmlEngDocument::CloneDocumentL() must be used.
Reimplemented in TXmlEngAttr, RXmlEngDocument, and TXmlEngElement. |
|
Creates a deep copy of the node and appends the subtree as a new child to the provided parent node.
|
|
Unlinks the internal libxml2's node from double-linked list. Relinks neighbour nodes.The node stays virtually linked to its old neighbours! Use with care!! No checks are made; nor parent's, nor node's properties updated
|
|
Get first child of current node.
|
|
Initializes a node list with all children of the node.
|
|
Check if node has attributes.
|
|
Check if node has child nodes.
|
|
Get innerXML string. This method returns all content of the node. Output text does not include node markup.
|
|
Check if nemespace is default for this node.
|
|
Check if node is NULL.
|
|
Compares nodes. The nodes are the same if they are referring to the same in-memory data structure.
|
|
Check if node content is "simple text".
|
|
Get last child of current node.
|
|
Inserts the node in a double-linked list of nodes before specified node. No checks are made; nor parent's, nor node's properties updated (except prev/next)
|
|
Searches the namespace URI that is bound to the given prefix.
|
|
Searches the prefix that is bound to the given aNamespaceUri and applicable in the scope of this TXmlEngNode.
|
|
Moves the node in the list of sibling nodes after another node Node is expected to have a parent. Do nothing if aSiblingNode is not one of the node's siblings
|
|
Moves the node in the list of sibling nodes before another node Node is expected to have a parent. Do nothing if aSiblingNode is not one of node's siblings
|
|
Moves the node to another part of the tree or another document The node is unliked from current postion (if any) and appended to the its new parent.
|
|
Get node name.
interface nodeName nodeValue attributes ------------------------------------------------------------------------------- Attr = Attr.name = Attr.value = null CDATASection = "#cdata-section" = CharacterData.data = null Comment = "#comment" = CharacterData.data = null Document = "#document" = null = null DocumentFragment = "#document-fragment" = null = null DocumentType = DocumentType.name = null = null Element = Element.tagName = null = NamedNodeMap Entity = entity name = null = null EntityReference = name of entity referenced = null = null Notation = notation name = null = null ProcessingInstruction = target = data = null Text = "#text" = CharacterData.data = null ------------------------------------------------------------------------------- Reimplemented in TXmlEngAttr. |
|
Retrieves a "handle" for namespace declaration that applies to the node's namespace Note: DOM specs do not consider namespace declarations as a kind of nodes This API adds TXmlEngNamespace type of nodes, which is derived from TXmlEngNode.
|
|
Get namespace uri.
|
|
Get fallowing node of current node.
|
|
Use NodeType() to find out the type of the node prior to casting object of TXmlEngNode class to one of its derived subclasses (TXmlEngElement, TXmlEngAttr, TXmlEngTextNode, etc. )
|
|
Check if node is NULL.
|
|
Get outerXML string. This method returns all content of the node. Output text includes node markup.
|
|
Get document handle.
|
|
Get parent node of current node.
|
|
Get namespace prefix.
Reimplemented in TXmlEngNamespace. |
|
Get previous node of current node.
|
|
Ensures that namespaces referred to in the node and its descendants are in the scope the node. This method checks that all the namespaces declared within the given tree are properly declared. This is needed for example after Copy or Unlink and then Append operations. The subtree may still hold pointers to namespace declarations outside the subtree or they may be invalid/masked. As much as possible the function try to reuse the existing namespaces found in the new environment. If not possible, the new namespaces are redeclared on the top of the subtree. This method should be used after unlinking nodes and inserting to another document tree or to a another part of the original tree, if some nodes of the subtree are remove from the scope of a namespace declaration they refer to. When node is unlinked, it may still refer to namespace declarations from the previous location. It is important to reconcile subtree's namespaces if previous parent tree is to be destroyed. On the other hand, if the parent tree is not changed before pasting its unlinked part into another tree, then reconciliation is needed only after paste operation.
|
|
Unlinks the node and destroys it; all child nodes are destroyed as well and all memory is freed.
Reimplemented in RXmlEngDocument. |
|
Removes the user data onject attached to this node. Ownership is transferred (the object is not deleted).
|
|
Current node is replaced with another node (subtree). The replacement node is linked into document tree instead of this node. The replaced node is destroyed.
Reimplemented in RXmlEngDocument. |
|
Moves the node to become the first in the list of its siblings Node is expected to have a parent.
|
|
Moves the node to become the last in the list of its siblings Node is expected to have a parent.
|
|
Sets value of this node.
Reimplemented in TXmlEngAttr. |
|
Another node is put instead of the current node. Does the same as ReplaceWith(TXmlEngNode) but does not free node and just returns it.
It is possible to use NULL TXmlEngNode object as an argument. In such case no new node will be put instead of unlinked one.
|
|
Detaches a node from document tree.
|
|
Returns the user data object attached to this node. Ownership is not transferred.
|
|
Fetches value of this node, depending on its type.
Reimplemented in TXmlEngAttr. |
|
Get copy of node's text content What is returned depends on the node type. Method caller is responsible for freeing returned string.
|
|
Node pointer. |