PrevNextUpHome BREW C++ Class Library & GUI Framework & XML Middleware : SophiaFramework 4.1
SFXXMLElement
[XML] Class that represents an Element node.
#include <SFXXMLElement.hpp>
class SFXXMLElement : public SFXXMLNode;
SFMTYPEDEFCLASS(SFXXMLElement)

Inheritance diagram

 Inheritance diagram of SFXXMLElementClass

Collaboration diagram

 Collaboration diagram of SFXXMLElementClass

Description

An Element node(SFXXMLElement) contains an element of the XML document.

An Attribute node(SFXXMLAttribute) can be set to the Element node using the functions such as SFXXMLElement::SetAttributeNode, SFXXMLElement::SetAttribute.

The Attribute node of the Element node can be obtained using the functions such as SFXXMLElement::GetAttributeNode, SFXXMLElement::GetAttributes.

Reference

SFXXMLNode | SFXXMLAttribute | SFXXMLCDATASection | SFXXMLComment | SFXXMLDocument | SFXXMLDocumentFragment | SFXXMLDocumentType | SFXXMLEntity | SFXXMLEntityReference | SFXXMLNotation | SFXXMLProcessingInstruction | SFXXMLText

Member

Constructor/Destructor
SFXXMLElement( SFXXMLDocumentPtr owner , SFXAnsiStringConstRef name )
Constructor of SFXXMLElement class.
SFXXMLElement( SFXXMLDocumentPtr owner , SFXAnsiStringConstRef name , SFXAnsiStringConstRef namespaceURI )
Constructor of SFXXMLElement class.
SFXXMLElement( SFXXMLElementConstRef other , Bool deep = false )
Constructor of SFXXMLElement class.
~SFXXMLElement( Void )
Destructor of SFXXMLElement class.
Public Functions
SFCError AppendChild( SFXXMLNodeConstPtr newchild )
Append a specified child node at the end.
SFCError CloneNode( SFXXMLNodeHandle clonenode , Bool deep )
Create a copy of this node.
Bool EqualNode( SFXXMLNodeConstPtr arg )
Check whether this node equals a specified node or not.
ACharConstPtr GetAttribute( SFXAnsiStringConstRef name )
Get the attribute value by name.
SFXXMLAttributePtr GetAttributeNode( SFXAnsiStringConstRef name )
Get the Attribute node by name.
DOMNamedNodeMapPtr GetAttributes( Void )
Get all the Attribute nodes.
DOMNodeListPtr GetChildNodes( Void )
Get all the child nodes.
DOMNodeListPtr GetElementsByTagName( SFXAnsiStringConstRef name )
Get all the Element nodes that match a specified tag name.
SFXXMLNodePtr GetFirstChild( Void )
Get the first child node.
SFXXMLNodePtr GetLastChild( Void )
Get the last child node.
ACharConstPtr GetLocalName( Void )
Get the local name.
ACharConstPtr GetName( Void )
Get the node name.
ACharConstPtr GetNamespaceURI( Void )
Get the namespace URI.
SFXXMLNodePtr GetNextSibling( Void )
Get the next sibling node.
ACharConstPtr GetNodeName( Void )
Get the node name.
NodeType GetNodeType( Void )
Get the node type.
SFXXMLNodePtr GetParentNode( Void )
Get the parent node.
ACharConstPtr GetPrefix( Void )
Get the prefix.
SFXXMLNodePtr GetPreviousSibling( Void )
Get the previous sibling node.
Bool HasAttribute( SFXAnsiStringConstRef name )
Check whether the Attribute node with a specified name exists or not.
Bool HasAttributes( Void )
Check whether any Attribute nodes exist or not.
Bool HasChildNodes( Void )
Check wheteher this node has any child nodes or not.
SFCError InsertBefore( SFXXMLNodeConstPtr newchild , SFXXMLNodeConstPtr refchild )
Insert a specified node.
Void RemoveAttribute( SFXAnsiStringConstRef name )
Remove the Attribute node by name.
SFXXMLAttributePtr RemoveAttributeNode( SFXXMLAttributePtr oldAttr )
Remove the Attribute node from the this node.
SFCError RemoveChild( SFXXMLNodeConstPtr oldchild )
Remove a specified child node including its descendant nodes.
SFCError ReplaceChild( SFXXMLNodeConstPtr newchild , SFXXMLNodeConstPtr oldchild )
Replace a specified child node.
Void SetAttribute( SFXAnsiStringConstRef name , ACharConstPtr value )
Set the attribute value.
SFCError SetAttributeNode( SFXXMLAttributePtr newAttr )
Set the Attribute node to this node.
ACharConstPtr GetNodeValue( Void ) (inherits from SFXXMLNode)
Get the node value.
SFXAnsiString GetText( Void ) (inherits from SFXXMLNode)
Get the node text.
Bool IsSameNode( SFXXMLNodeConstPtr other ) (inherits from SFXXMLNode)
Check whether this node is the same as a specified one or not.
Void SetNodeValue( ACharConstPtr value ) (inherits from SFXXMLNode)
Set the node value.
SFCError SetText( SFXAnsiStringConstRef text ) (inherits from SFXXMLNode)
Set the node text.
Types
DOMNamedNodeMap (inherits from SFXXMLNode)
Class to manage the DOM nodes by name
DOMNodeList (inherits from SFXXMLNode)
Class to manage the DOM nodes by list
NodeType (inherits from SFXXMLNode)
SFXXMLNode::NodeType is an enumeration type of NodeType values defined in the W3C DOM Level 1 Specification. Document Object Model (DOM) Level 1 Specification )

SFXXMLElement::SFXXMLElement
Constructor of SFXXMLElement class.
[ public, explicit ]
SFXXMLElement(
    SFXXMLDocumentPtr owner      // root node of the DOM tree
    SFXAnsiStringConstRef name   // name of the Element node
);
[ public, explicit ]
SFXXMLElement(
    SFXXMLDocumentPtr owner              // root node of the DOM tree
    SFXAnsiStringConstRef name           // name of the Element node
    SFXAnsiStringConstRef namespaceURI   // namespace URI of the Element node
);
[ public, explicit ]
SFXXMLElement(
    SFXXMLElementConstRef other   // Element node
    Bool deep = false             // whether or not to copy the child nodes recursively
);

SFXXMLElement::~SFXXMLElement
Destructor of SFXXMLElement class.
[ public, virtual ]
virtual ~SFXXMLElement(Void);

SFXXMLElement::AppendChild
Append a specified child node at the end.
[ public, virtual ]
SFCError AppendChild(
    SFXXMLNodeConstPtr newchild   // child node to append
);

Return value

  • Success : SFERR_NO_ERROR
  • If invalid argument : SFERR_INVALID_PARAM
  • If insufficient memory : SFERR_NO_MEMORY
  • If failed : SFERR_FAILED

Description

The "newchild" node is appended as the last child node to this node without copying it.

If the "newchild" node belongs to a DOM tree, it will be removed from that tree.

Reference

SFXXMLNode::AppendChild | SFXXMLNode


SFXXMLElement::CloneNode
Create a copy of this node.
[ public, virtual ]
SFCError CloneNode(
    SFXXMLNodeHandle clonenode   // target node where to copy this node(Handle type)
    Bool deep                    // whether or not to copy the child nodes recursively
);

Argument

clonenode

Specify the target node where to copy this node.

deep

If true is set to this argument, copy the child nodes recursively.

Otherwise, copy only this node and its Attribute nodes.

Return value

  • Success : SFERR_NO_ERROR
  • If failed : SFERR_FAILED

Reference

SFXXMLNode::CloneNode | SFXXMLNode


SFXXMLElement::EqualNode
Check whether this node equals a specified node or not.
[ public, virtual, const ]
Bool EqualNode(
    SFXXMLNodeConstPtr arg   // specified node
);

Return value

  • If yes : true
  • Otherwise : false

Reference

SFXXMLNode::EqualNode | SFXXMLNode


SFXXMLElement::GetAttribute
Get the attribute value by name.
[ public, const ]
ACharConstPtr GetAttribute(
    SFXAnsiStringConstRef name   // name of attribute to be retrieved
);

Argument

name

Qualified name and namespace URI can be specified as attribute name.

Return value

null is returned if this node has no attribute value.

Description

The attribute value can be obtained by qualified name and namespace URI

Example

// get "xmlns:dt" attribute value 
SFXAnsiString atti = boot->GetAttribute("xmlns:dt");

Reference

SFXXMLElement::GetAttributes | SFXXMLElement::GetAttributeNode | SFXXMLElement::SetAttribute | SFXXMLElement::SetAttributeNode | SFXXMLElement::HasAttribute | SFXXMLElement::HasAttributes | SFXXMLElement::RemoveAttribute | SFXXMLElement::RemoveAttributeNode


SFXXMLElement::GetAttributeNode
Get the Attribute node by name.
[ public, const ]
SFXXMLAttributePtr GetAttributeNode(
    SFXAnsiStringConstRef name   // name of the Attribute node to get
);

Argument

name

Qualified name and namespace URI can be specified for the Attribute name.

Return value

Return the Attribute node with a specified name. Return null if no Attribute node with this name is found.

Description

The Attribute node can be correctly obtained by specifying the qualified name and namespace URI.

Example

// get "xmlns:dt" Attribute node 
SFXXMLAttributePtr atti = boot->GetAttributeNode("xmlns:dt");

Reference

SFXXMLElement::GetAttribute | SFXXMLElement::GetAttributeNode | SFXXMLElement::SetAttribute | SFXXMLElement::SetAttributeNode | SFXXMLElement::HasAttribute | SFXXMLElement::HasAttributes | SFXXMLElement::RemoveAttribute | SFXXMLElement::RemoveAttributeNode


SFXXMLElement::GetAttributes
Get all the Attribute nodes.
[ public, const ]
DOMNamedNodeMapPtr GetAttributes(Void);

Return value

Return the pointer to the Attribute nodes of the SFXXMLNode::DOMNamedNodeMap if any. Return null if not.

Example

// check whether this Element node has any Attribute nodes or not  
if (SFXXMLElementPtr(child)->HasAttributes()) {
    // get all the Attribute nodes of this Element node 
    SFXXMLNode::DOMNamedNodeMapPtr attr = SFXXMLElementPtr(child)->GetAttributes();
    if (attr) {
        for (int i = 0; i < attr->GetLength(); i++) {
            SFXXMLNodePtr item = attr->Item(i);
            if (item) {
                if(item->GetNodeType() == SFXXMLNode::ATTRIBUTE_NODE);
                ...
            }                            
        }
    }
}

Reference

SFXXMLNode::DOMNamedNodeMap | SFXXMLElement::GetAttribute | SFXXMLElement::SetAttribute | SFXXMLElement::SetAttributeNode | SFXXMLElement::HasAttribute | SFXXMLElement::HasAttributes | SFXXMLElement::GetAttributeNode | SFXXMLElement::RemoveAttribute | SFXXMLElement::RemoveAttributeNode


SFXXMLElement::GetChildNodes
Get all the child nodes.
[ public, virtual, const ]
DOMNodeListPtr GetChildNodes(Void);

Return value

Return the pointer to the SFXXMLNode::DOMNodeList instance that contains all child nodes of this node.

Description

[Note] Note
Each element of SFXXMLNode::DOMNodeList is of the "pointer to the SFXXMLNode" type.

Example

//get element node by tag name
SFXXMLNode::DOMNodeListPtr list = root->GetElementsByTagName("BOOK");

 if (list) {
    // get the enumerator
    SFXXMLNode::DOMNodeList::Enumerator enumer = list->GetFirstEnumerator();

    while (enumer.HasNext()) {
        // get each element node
        SFXXMLElementPtr elem = static_cast<SFXXMLElementPtr>(enumer.GetNext());
        // get all child nodes of each element node
        SFXXMLNode::DOMNodeListPtr nodeList = elem->GetChildNodes();
        // get enumrator of child nodes
        SFXXMLNode::DOMNodeList::Enumerator childiter = nodeList->GetFirstEnumerator();

        while (childiter.HasNext()) {
            SFXXMLElementPtr child = static_cast<SFXXMLElementPtr>(childiter.GetNext());

            TRACE("child name: %s", child->GetName());    // display name of each child node
            TRACE("child text: %s", child->GetText().GetCString());  // display child node string content
        }
    }
}

Reference

SFXXMLNode::DOMNodeList | SFXXMLNode::GetChildNodes| SFXXMLNode


SFXXMLElement::GetElementsByTagName
Get all the Element nodes that match a specified tag name.
[ public, const ]
DOMNodeListPtr GetElementsByTagName(
    SFXAnsiStringConstRef name   // tag name
);

Return value

Return all the Element nodes that match a specified tag name as the pointer to the SFXXMLNode::DOMNodeList instance.

Reference

SFXXMLNode::DOMNodeList | SFXXMLDocument::GetElementsByTagName


SFXXMLElement::GetFirstChild
Get the first child node.
[ public, virtual, const ]
SFXXMLNodePtr GetFirstChild(Void);

Return value

Return the first child node of this node. Return null if this node has no child.

Reference

SFXXMLNode::GetFirstChild | SFXXMLNode


SFXXMLElement::GetLastChild
Get the last child node.
[ public, virtual, const ]
SFXXMLNodePtr GetLastChild(Void);

Return value

Return the last child node of this node. Return null if this node has no child.

Reference

SFXXMLNode::GetLastChild | SFXXMLNode


SFXXMLElement::GetLocalName
Get the local name.
[ public, const ]
ACharConstPtr GetLocalName(Void);

Return value

Return the local name of this node.

Description

When the name set to this node is qualified name, it is a pair of namespace prefix and local name.

[Note] Note
The name of the Element node is the element name of the XML document.

Reference

SFXXMLElement::GetPrefix | SFXXMLElement::GetName | SFXXMLElement::GetNamespaceURI


SFXXMLElement::GetName
Get the node name.
[ public, const ]
ACharConstPtr GetName(Void);

Description

Same as the SFXXMLElement::GetNodeName function.

[Note] Note
The name of the Element node is the element name of the XML document.
[Note] Note
When the namespace is set, the qualified name(namespace prefix and local name) is returned.

Example

<?xml version="1.0" encoding="Shift_JIS"?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://www.w3.org/1999/xhtml"
    version="1.0">
<xsl:output encoding="Shift_JIS"  method="xml"
    doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
    doctype-system="DTD/xhtml1-transitional.dtd"/>
	<xsl:template match="/">
	    <html>
	        <head>
	           <title>words</title>
	        </head>
	        <body bgcolor="#CCFFFF">
	            <center>
	                <table border="0">
	                    <xsl:apply-templates select=".//def"/>
	                </table>
	            </center>
	        </body>
	    </html>
	</xsl:template>
	<xsl:template match="def">
	    <tr><td><b><xsl:apply-templates/></b></td></tr>
	</xsl:template>
	<xsl:template match="text()">
	    <xsl:value-of select="."/>
	</xsl:template>
</xsl:stylesheet>


// get Element node
SFXXMLElementPtr stylesheet = document.GetDocumentElement();
TRACE("Element's name = %s", stylesheet->GetName());           // name as qualified name = xsl:stylesheet 
TRACE("Element's localname = %s", stylesheet->GetLocalName()); // local name             = stylesheet 
TRACE("Element's prefix = %s", stylesheet->GetPrefix());       // prefix   	          = xsl 
TRACE("Element's uri = %s", stylesheet->GetNamespaceURI());    // namespace URI          = http://www.w3.org/1999/XSL/Transform 
 

Reference

SFXXMLElement::GetLocalName | SFXXMLElement::GetNodeName | SFXXMLElement::GetPrefix | SFXXMLElement::GetNamespaceURI


SFXXMLElement::GetNamespaceURI
Get the namespace URI.
[ public, const ]
ACharConstPtr GetNamespaceURI(Void);

Return value

Return the namespace URI of this node if set. Otherwise, return null.

Reference

SFXXMLElement::GetPrefix | SFXXMLElement::GetName | SFXXMLElement::GetLocalName


SFXXMLElement::GetNextSibling
Get the next sibling node.
[ public, virtual, const ]
SFXXMLNodePtr GetNextSibling(Void);

Return value

Return the next sibling node of this node. If this node has no next sibling node, null is returned.

Example

SFXXMLDOMParser parser;    // parse XML document by DOM method

// get root node of DOM tree
SFXXMLDocumentPtr root = parser.GetDocument();

// get first child of root node
SFXXMLNodePtr node = root->GetFirstChild();

SFXXMLElementPtr elem = static_cast<SFXXMLElementPtr>(node); // convert into Element pointer type   

SFXXMLNodePtr child = elem->GetFirstChild();     // get first child node    
SFXXMLNodePtr author = child->GetNextSibling();  // get next sibling node

Reference

SFXXMLElement::GetPreviousSibling | SFXXMLNode::GetNextSibling| SFXXMLNode::GetPreviousSibling | SFXXMLNode


SFXXMLElement::GetNodeName
Get the node name.
[ public, virtual, const ]
ACharConstPtr GetNodeName(Void);

Description

Same as the SFXXMLElement::GetName function.

[Note] Note
The name of the Element node is the element name of the XML document.
[Note] Note
When the namespace is set, the qualified name(namespace prefix and local name) is returned.

Reference

SFXXMLElement::GetName | SFXXMLNode::GetNodeName | SFXXMLNode


SFXXMLElement::GetNodeType
Get the node type.
[ public, virtual, const ]
NodeType GetNodeType(Void);

Return value

Return ELEMENT_NODE.

Reference

SFXXMLNode::NodeType | SFXXMLNode::GetNodeType | SFXXMLNode


SFXXMLElement::GetParentNode
Get the parent node.
[ public, virtual, const ]
SFXXMLNodePtr GetParentNode(Void);

Return value

Return the parent node of this node. Return null if this node has no parent.

Reference

SFXXMLNode::GetParentNode | SFXXMLNode


SFXXMLElement::GetPrefix
Get the prefix.
[ public, const ]
ACharConstPtr GetPrefix(Void);

Return value

Return the prefix of this node if set. Otherwise return null.

Reference

SFXXMLElement::GetName


SFXXMLElement::GetPreviousSibling
Get the previous sibling node.
[ public, virtual, const ]
SFXXMLNodePtr GetPreviousSibling(Void);

Return value

Return the previous sibling node of this node. If this node has no previous sibling node, null is returned.

Reference

SFXXMLElement::GetNextSibling | SFXXMLNode::GetPreviousSibling | SFXXMLNode::GetNextSibling | SFXXMLNode


SFXXMLElement::HasAttribute
Check whether the Attribute node with a specified name exists or not.
[ public, const ]
Bool HasAttribute(
    SFXAnsiStringConstRef name   // attribute name
);

return value

  • has specified attribute : true
  • does not have : false

Example

// check whether the Attribute node with name of "isdn" exists or not 
if(book->HasAttribute("isdn") == false){
    .....
}

Reference

SFXXMLElement::HasAttributes | SFXXMLElement::SetAttribute | SFXXMLElement::SetAttributeNode | SFXXMLElement::SetAttribute | SFXXMLElement::SetAttributeNode | SFXXMLElement::GetAttribute | SFXXMLElement::GetAttributes | SFXXMLElement::RemoveAttribute | SFXXMLElement::RemoveAttributeNode


SFXXMLElement::HasAttributes
Check whether any Attribute nodes exist or not.
[ public, const ]
Bool HasAttributes(Void);

Example

// check whether any Attribute nodes exist or not
if(book->HasAttributes() == false){
    .....
}

Reference

SFXXMLElement::HasAttribute | SFXXMLElement::GetAttribute | SFXXMLElement::GetAttributes | SFXXMLElement::RemoveAttribute | SFXXMLElement::RemoveAttributeNode


SFXXMLElement::HasChildNodes
Check wheteher this node has any child nodes or not.
[ public, virtual, const ]
Bool HasChildNodes(Void);

Return value

  • If yes : true
  • Otherwise : false

Reference

SFXXMLNode::HasChildNodes | SFXXMLNode


SFXXMLElement::InsertBefore
Insert a specified node.
[ public, virtual ]
SFCError InsertBefore(
    SFXXMLNodeConstPtr newchild   // node to insert
    SFXXMLNodeConstPtr refchild   // newchild node is inserted before refchild node
);

Return value

  • Success : SFERR_NO_ERROR
  • If invalid argument : SFERR_INVALID_PARAM
  • If insufficient memory : SFERR_NO_MEMORY
  • If failed : SFERR_FAILED

Description

Insert the newchild node before the refchild node. If the refchild argument is specified as null, append the newchild node as the last child node.

When the newchild node is the DocumentFragment node, all the child nodes of the newchild node are inserted in the same order before the refchild node.

When the newchild node has already existed in the DOM tree, it is removed before insertion.

Example

// create Element node    
SFXXMLElementPtr isbn = document.CreateElement("ISBN");
// add Text node to Element node   
isbn->AppendChild(SFXXMLNodePtr(document.CreateTextNode("4-7741-1616-5")));
// insert Element node   
book->InsertBefore(SFXXMLNodePtr(isbn), book->GetFirstChild());
 

Reference

SFXXMLNode::InsertBefore | SFXXMLNode


SFXXMLElement::RemoveAttribute
Remove the Attribute node by name.
[ public ]
Void RemoveAttribute(
    SFXAnsiStringConstRef name   // attribute name to remove
);

Description

If the Attribute node that match a specified name does not exist, this function is invalid .

[Note] Note
Qualified name(namespace prefix and local name) can be specified.

Example

// remove "dt:dt" Attribute node of "date" Element node 
date->RemoveAttribute("dt:dt");

Reference

SFXXMLElement::GetAttribute | SFXXMLElement::SetAttributeNode | SFXXMLElement::GetAttributeNode | SFXXMLElement::SetAttribute | SFXXMLElement::RemoveAttributeNode


SFXXMLElement::RemoveAttributeNode
Remove the Attribute node from the this node.
[ public ]
SFXXMLAttributePtr RemoveAttributeNode(
    SFXXMLAttributePtr oldAttr   // Attribute node to remove
);

Return value

Return the removed Attribute node (SFXXMLAttribute).

Example

// get "dt:dt" Attrubite node
SFXXMLAttributePtr atti = book->GetAttributeNode("dt:dt");
// remove this Attribite node from DOMNamedNodeMap
book->RemoveAttributeNode(atti);
// delete this node
delete atti;

Reference

SFXXMLAttribute | SFXXMLElement::GetAttribute | SFXXMLElement::SetAttributeNode | SFXXMLElement::GetAttributeNode | SFXXMLElement::SetAttribute | SFXXMLElement::RemoveAttribute


SFXXMLElement::RemoveChild
Remove a specified child node including its descendant nodes.
[ public, virtual ]
SFCError RemoveChild(
    SFXXMLNodeConstPtr oldchild   // child node to remove
);

Return value

  • Success : SFERR_NO_ERROR
  • If invalid parameter : SFERR_INVALID_PARAM
  • If failed : SFERR_FAILED

Reference

SFXXMLNode::RemoveChild| SFXXMLNode


SFXXMLElement::ReplaceChild
Replace a specified child node.
[ public, virtual ]
SFCError ReplaceChild(
    SFXXMLNodeConstPtr newchild   // new child node to replace with
    SFXXMLNodeConstPtr oldchild   // old child node to be replaced
);

Return value

  • Success : SFERR_NO_ERROR
  • If invalid argument : SFERR_INVALID_PARAM
  • If insufficient memory : SFERR_NO_MEMORY
  • If failed : SFERR_FAILED

Example

// create the name node   
SFXXMLElementPtr name = document.CreateElement("NAME");
// set a text to the name node
name->AppendChild(SFXXMLNodePtr(document.CreateTextNode("Cosmos")));
// replace the first child of book node with the name node
book->ReplaceChild(name, book->GetFirstChild());

Reference

SFXXMLNode::ReplaceChild| SFXXMLNode


SFXXMLElement::SetAttribute
Set the attribute value.
[ public ]
Void SetAttribute(
    SFXAnsiStringConstRef name   // attribute name to set
    ACharConstPtr value          // attribute value to set
);

Description

If the attribute with a specified name already exists, new value is set to this attribute.

[Note] Note
Qualified name(namespace prefix and local name) can be specified.
[Note] Method to set the attribute value including an entity reference

To set the attribute value including entity reference, specify the Attribute node(SFXXMLAttribute) that has any Text nodes(SFXXMLText) and a SFXXMLEntityReference node for an argument of the SFXXMLElement::SetAttributeNode function.

Reference

SFXXMLElement::SetAttributeNode | SFXXMLElement::GetAttribute | SFXXMLElement::GetAttributeNode | SFXXMLElement::HasAttribute | SFXXMLElement::HasAttributes | SFXXMLElement::RemoveAttribute | SFXXMLElement::RemoveAttributeNode


SFXXMLElement::SetAttributeNode
Set the Attribute node to this node.
[ public ]
SFCError SetAttributeNode(
    SFXXMLAttributePtr newAttr   // Attribute node to set
);

Return value

  • Success : SFERR_NO_ERROR
  • If invalid argument : SFERR_INVALID_PARAM
  • If insufficient memory : SFERR_NO_MEMORY

Description

If the Attribute node with the same name of specified Attribute node exists, it will be deleted and replaced with a specified Attribute node.

Example

// create isdn attribute (attribute value is set, too)
SFXXMLAttributePtr atti = document.CreateAttribute("isdn","4-7741-1616-5");
// add attribute to BOOK element
book->SetAttributeNode(atti);

Reference

SFXXMLElement::SetAttribute | SFXXMLElement::GetAttribute | SFXXMLElement::GetAttributeNode | SFXXMLElement::HasAttribute | SFXXMLElement::HasAttributes | SFXXMLElement::RemoveAttribute | SFXXMLElement::RemoveAttributeNode