PrevNextUpHome SophiaFramework UNIVERSE 5.3
SFXXMLElement
[XML] Class which 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 the SFXXMLElement class.
SFXXMLElement( SFXXMLDocumentPtr owner , SFXAnsiStringConstRef name , SFXAnsiStringConstRef namespaceURI )
Constructor of the SFXXMLElement class.
SFXXMLElement( SFXXMLElementConstRef other , Bool deep = false )
Constructor of the SFXXMLElement class.
~SFXXMLElement( Void )
Destructor of the SFXXMLElement class.
Public Functions
SFCError AppendChild( SFXXMLNodeConstPtr newchild )
Append the 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 the specified node or not.
ACharConstPtr GetAttribute( SFXAnsiStringConstRef name )
Get the value of the attribute with the specified name.
ACharConstPtr GetAttributeNS( SFXAnsiStringConstRef localname , SFXAnsiStringConstRef namespaceURI )
Get the value of the attribute with the specified local name and namespace URI.
SFXXMLAttributePtr GetAttributeNode( SFXAnsiStringConstRef name )
Get the Attribute node with the specified name.
SFXXMLAttributePtr GetAttributeNodeNS( SFXAnsiStringConstRef localname , SFXAnsiStringConstRef namespaceURI )
Get the Attribute node with the specified local name and namespace URI.
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 the specified tag name.
DOMNodeListPtr GetElementsByTagNameNS( SFXAnsiStringConstRef localname , SFXAnsiStringConstRef namespaceURI )
Get all the Element nodes that match the specified local name and namespace URI.
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 or not the attribute with the specified name exists.
Bool HasAttributeNS( SFXAnsiStringConstRef localname , SFXAnsiStringConstRef namespaceURI )
Check whether or not the attribute with the specified local name and namespace URI exists.
Bool HasAttributes( Void )
Check whether any Attribute nodes exist or not.
Bool HasChildNodes( Void )
Check wheteher or not this node has any child nodes.
SFCError InsertBefore( SFXXMLNodeConstPtr newchild , SFXXMLNodeConstPtr refchild )
Insert the specified node.
Void RemoveAttribute( SFXAnsiStringConstRef name )
Remove the attribute with the specified name(QName).
Void RemoveAttributeNS( SFXAnsiStringConstRef localname , SFXAnsiStringConstRef namespaceURI )
Remove the attribute with the specified local name and namespace URI.
SFXXMLAttributePtr RemoveAttributeNode( SFXXMLAttributePtr oldAttr )
Remove the specified Attribute node from this node.
SFCError RemoveChild( SFXXMLNodeConstPtr oldchild )
Remove the specified child node including its descendant nodes.
SFCError ReplaceChild( SFXXMLNodeConstPtr newchild , SFXXMLNodeConstPtr oldchild )
Replace the specified child node.
Void SetAttribute( SFXAnsiStringConstRef name , ACharConstPtr value )
Set the attribute with the specified name to the specified value.
Void SetAttributeNS( SFXAnsiStringConstRef localname , SFXAnsiStringConstRef namespaceURI , ACharConstPtr value )
Set the attribute with the specified local name and namespace URI to the specified value.
SFCError SetAttributeNode( SFXXMLAttributePtr newAttr )
Set the specified Attribute node to this node.
SFCError SetAttributeNodeNS( SFXXMLAttributePtr newAttr )
Set the specified 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 the 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 the 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 the SFXXMLElement class.
[ public, virtual ]
virtual ~SFXXMLElement(Void);

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

Return value

  • If succeeds: SFERR_NO_ERROR
  • If the newchild argument is invalid: SFERR_INVALID_PARAM
  • If insufficient memory: SFERR_NO_MEMORY

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

SFXXMLElement::InsertBefore | 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

  • If succeeds: SFERR_NO_ERROR
  • If failed: SFERR_FAILED

Reference

SFXXMLNode::CloneNode | SFXXMLNode


SFXXMLElement::EqualNode
Check whether this node equals the 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 value of the attribute with the specified name.
[ public, const ]
ACharConstPtr GetAttribute(
    SFXAnsiStringConstRef name   // name of the attribute: QName can be specified if namespace is set
);

Argument

name

Specify the name of the attribute. Capital letters and small letters are distinguished. QName can be specified if namespace is set.

Return value

Value of the attribute with the specified name.

Description

This function gets the value of the attribute with the specified name.

null will be returned if this node has no attribute value.

[Note] Note

QName can be specified in the name argument if namespace is set.

[Note] Note

When the attribute is specified with the local name and the namespace URI, the SFXXMLElement::GetAttributeNS function will be used.

Example

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

Reference

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


SFXXMLElement::GetAttributeNS
Get the value of the attribute with the specified local name and namespace URI.
[ public, const ]
ACharConstPtr GetAttributeNS(
    SFXAnsiStringConstRef localname      // local name of the attribute
    SFXAnsiStringConstRef namespaceURI   // namespace URI of the attribute
);

引数

localname

Specify the local name of the attribute(Capital letters and small letters are distinguished).

namespaceURI

Specify the namespace URI of the attribute.

Return value

Value of the attribute with the specified local name and namespace URI.

Description

This function gets the value of the attribute with the specified local name and namespace URI.

[Note] Note

null will be returned if this node has no attribute value.

[Note] Note

When the attribute is specified with the QName, the SFXXMLElement::GetAttribute function will be used.

Reference

SFXXMLElement::GetAttribute | SFXXMLNode::DOMNamedNodeMap | SFXXMLElement::GetAttributeNodeNS | SFXXMLElement::GetAttributes | SFXXMLElement::SetAttributeNS | SFXXMLElement::SetAttributeNodeNS | SFXXMLElement::HasAttributeNS | SFXXMLElement::HasAttributes | SFXXMLElement::RemoveAttributeNS


SFXXMLElement::GetAttributeNode
Get the Attribute node with the specified name.
[ public, const ]
SFXXMLAttributePtr GetAttributeNode(
    SFXAnsiStringConstRef name   // name of the attribute: QName can be specified if namespace is set
);

Argument

name

Specify the name of the attribute. Capital letters and small letters are distinguished. QName can be specified if namespace is set.

Return value

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

Description

This function gets the Attribute node with the specified name.

[Note] Note

QName can be specified in the name argument if namespace is set.

[Note] Note

When the attribute is specified with the local name and the namespace URI, the SFXXMLElement::GetAttributeNodeNS function will be used.

Example

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

Reference

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


SFXXMLElement::GetAttributeNodeNS
Get the Attribute node with the specified local name and namespace URI.
[ public, const ]
SFXXMLAttributePtr GetAttributeNodeNS(
    SFXAnsiStringConstRef localname      // local name of the attribute
    SFXAnsiStringConstRef namespaceURI   // namespace URI of the attribute
);

引数

localname

Specify the local name of the attribute(Capital letters and small letters are distinguished).

namespaceURI

Specify the namespace URI of the attribute.

Return value

Return the Attribute node with the specified local name and namespace URI. Return null if no Attribute node with the specified local name and namespace URI is found.

Description

This function gets the Attribute node with the specified name(QName).

[Note] Note

When the attribute is specified with the name, the SFXXMLElement::GetAttributeNode function will be used.

Reference

SFXXMLElement::GetAttributeNode | SFXXMLNode::DOMNamedNodeMap | SFXXMLElement::GetAttributeNS | SFXXMLElement::GetAttributes | SFXXMLElement::SetAttributeNS | SFXXMLElement::SetAttributeNodeNS | SFXXMLElement::HasAttributeNS | SFXXMLElement::HasAttributes | SFXXMLElement::RemoveAttributeNS


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 the specified tag name.
[ public, const ]
DOMNodeListPtr GetElementsByTagName(
    SFXAnsiStringConstRef name   // tag name: QName can be specified if namespace is set
);

Argument

name

Specify the tag name. Capital letters and small letters are distinguished. QName can be specified if namespace is set.

Return value

All the Element nodes with the specified tag name are returned as the pointer to the SFXXMLNode::DOMNodeList instance.

Description

This function gets all the Element nodes that match the specified tag name.

[Note] Note

When namespace is set, QName(i.e., "namespace prefix:local name") can be specified as a tag name.

[Note] Note

When the local name and the namespace URI are specified, the SFXXMLElement::GetElementsByTagNameNS function will be used.

Reference

SFXXMLElement::GetElementsByTagNameNS | SFXXMLNode::DOMNodeList | SFXXMLDocument::GetElementsByTagName


SFXXMLElement::GetElementsByTagNameNS
Get all the Element nodes that match the specified local name and namespace URI.
[ public, const ]
DOMNodeListPtr GetElementsByTagNameNS(
    SFXAnsiStringConstRef localname      // local name of the element
    SFXAnsiStringConstRef namespaceURI   // namespace URI of the element
);

引数

localname

Specify the local name of the element. Capital letters and small letters are distinguished.

namespaceURI

Specify the namespace URI of the element.

Return value

Return all the Element nodes that match the specified local name and namespace URI as the pointer to the SFXXMLNode::DOMNodeList instance.

Description

This function gets all the Element nodes that match the specified local name and namespace URI.

[Note] Note

When the tag name is specified, the SFXXMLElement::GetElementsByTagName function will be used.

Reference

SFXXMLElement::GetElementsByTagName | SFXXMLDocument::GetElementsByTagNameNS | SFXXMLNode::DOMNodeList


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 or not the attribute with the specified name exists.
[ public, const ]
Bool HasAttribute(
    SFXAnsiStringConstRef name   // name of the attribute: QName can be specified if namespace is set
);

Argument

name

Specify the name of the attribute. Capital letters and small letters are distinguished. QName can be specified if namespace is set.

return value

  • If yes: true
  • Otherwise: false

Description

This function checks whether or not the attribute with the specified name exists.

[Note] Note

QName can be specified in the name argument if namespace is set.

[Note] Note

When the attribute is specified with the local name and the namespace URI, the SFXXMLElement::HasAttributeNS function will be used.

Example

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

Reference

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


SFXXMLElement::HasAttributeNS
Check whether or not the attribute with the specified local name and namespace URI exists.
[ public, const ]
Bool HasAttributeNS(
    SFXAnsiStringConstRef localname      // local name of the attribute
    SFXAnsiStringConstRef namespaceURI   // namespace URI of the attribute
);

Argument

localname

Specify the local name of the attribute(Capital letters and small letters are distinguished).

namespaceURI

Specify the namespace URI of the attribute.

return value

  • If yes: true
  • Otherwise: false

Description

This function checks whether or not the attribute with the specified local name and namespace URI exists.

[Note] Note

When the attribute is specified with the name, the SFXXMLElement::HasAttribute function will be used.

Reference

SFXXMLElement::HasAttribute | SFXXMLNode::DOMNamedNodeMap | SFXXMLElement::HasAttributes | SFXXMLElement::SetAttributeNS | SFXXMLElement::SetAttributeNodeNS | SFXXMLElement::GetAttributeNS | SFXXMLElement::GetAttributeNodeNS | SFXXMLElement::GetAttributes | SFXXMLElement::RemoveAttributeNS


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 or not this node has any child nodes.
[ public, virtual, const ]
Bool HasChildNodes(Void);

Return value

  • If yes: true
  • Otherwise: false

Reference

SFXXMLNode::HasChildNodes | SFXXMLNode


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

Return value

  • If succeeds: SFERR_NO_ERROR
  • If the newchild / refchild argument is invalid: SFERR_INVALID_PARAM
  • If insufficient memory: SFERR_NO_MEMORY

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 with the specified name(QName).
[ public ]
Void RemoveAttribute(
    SFXAnsiStringConstRef name   // name(QName) of the attribute to remove
);

Argument

name

Specify the name(QName) of the attribute.

Description

This function removes the attribute with the specified name(QName).

If the attribute with the specified name(QName) does not exist, no attribute will be removed.

[Note] Note

When the attribute is specified with the local name and the namespace URI, the SFXXMLElement::RemoveAttributeNS function will be used.

Example

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

Reference

SFXXMLElement::RemoveAttributeNS | SFXXMLElement::RemoveAttributeNode | SFXXMLElement::GetAttribute | SFXXMLElement::GetAttributeNode | SFXXMLElement::GetAttributes | SFXXMLElement::HasAttribute | SFXXMLElement::HasAttributes | SFXXMLElement::SetAttribute | SFXXMLElement::SetAttributeNode


SFXXMLElement::RemoveAttributeNS
Remove the attribute with the specified local name and namespace URI.
[ public ]
Void RemoveAttributeNS(
    SFXAnsiStringConstRef localname      // local name of the attribute
    SFXAnsiStringConstRef namespaceURI   // namespace URI of the attribute
);

引数

localname

Specify the local name of the attribute(Capital letters and small letters are distinguished).

namespaceURI

Specify the namespace URI of the attribute.

Description

This function removes the attribute with the specified local name and namespace URI.

If the attribute with the specified local name and namespace URI does not exist, no attribute will be removed.

[Note] Note

When the attribute is specified with the QName, the SFXXMLElement::RemoveAttribute function will be used.

Reference

SFXXMLElement::RemoveAttribute | SFXXMLElement::GetAttributeNS | SFXXMLElement::GetAttributeNodeNS | SFXXMLElement::GetAttributes | SFXXMLElement::HasAttributeNS | SFXXMLElement::HasAttributes | SFXXMLElement::SetAttributeNS | SFXXMLElement::SetAttributeNodeNS | SFXXMLElement::RemoveAttributeNode


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

Return value

Return the removed Attribute node (SFXXMLAttribute).

Description

This function removes the specified Attribute node from this node.

Concretely, the specified Attribute node will be removed from the SFXXMLNode::DOMNamedNodeMap object which contains the attribute information on this Element node.

The return value of this function is the removed Attribute node.

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

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


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

Return value

  • If succeeds: SFERR_NO_ERROR
  • If the old argument is null or is not the child node of this node: SFERR_INVALID_PARAM
  • If failed: SFERR_FAILED

Reference

SFXXMLNode::RemoveChild| SFXXMLNode


SFXXMLElement::ReplaceChild
Replace the 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

  • If succeeds: SFERR_NO_ERROR
  • If newchild / oldchild argument is invalid: 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

SFXXMLElement::InsertBefore | SFXXMLElement::RemoveChild | SFXXMLNode::ReplaceChild| SFXXMLNode


SFXXMLElement::SetAttribute
Set the attribute with the specified name to the specified value.
[ public ]
Void SetAttribute(
    SFXAnsiStringConstRef name   // name of the attribute to set: QName can be specified if namespace is set
    ACharConstPtr value          // value of the attribute to set
);

Argument

name

Specify the name of the attribute. Capital letters and small letters are distinguished. QName can be specified if namespace is set.

value

Specify the value of the attribute.

Description

If the attribute with the specified name already exists, new value will be set to this attribute.

[Note] Note

QName can be specified in the name argument if namespace is set.

[Note] Note

When the attribute is specified with the local name and the namespace URI, the SFXXMLElement::SetAttributeNS function will be used.

Reference

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


SFXXMLElement::SetAttributeNS
Set the attribute with the specified local name and namespace URI to the specified value.
[ public ]
Void SetAttributeNS(
    SFXAnsiStringConstRef localname      // local name of the attribute
    SFXAnsiStringConstRef namespaceURI   // namespace URI of the attribute
    ACharConstPtr value                  // value of the attribute to set
);

Argument

localname

Specify the local name of the attribute(Capital letters and small letters are distinguished).

namespaceURI

Specify the namespace URI of the attribute.

value

Specify the value of the attribute.

Description

If the attribute with the specified local name and namespace URI already exists, new value will be set to this attribute.

[Note] Note

When the attribute is specified with the name, the SFXXMLElement::SetAttribute function will be used.

Reference

SFXXMLElement::SetAttribute | SFXXMLNode::DOMNamedNodeMap | SFXXMLElement::SetAttributeNodeNS | SFXXMLElement::GetAttributeNS | SFXXMLElement::GetAttributeNodeNS | SFXXMLElement::GetAttributes | SFXXMLElement::HasAttributeNS | SFXXMLElement::HasAttributes | SFXXMLElement::RemoveAttributeNS


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

Return value

  • If succeeds: SFERR_NO_ERROR
  • If the newAttr argument is not an Attribute node: SFERR_INVALID_PARAM
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function set the specified Attribute node to the SFXXMLNode::DOMNamedNodeMap object which this node contains internally.

When the Attribute node with the same name already exists in the SFXXMLNode::DOMNamedNodeMap object, the existing Attribute node will be removed and replaced with the specified Attribute node.

[Note] Note

When the specified Attribute node is searched from the SFXXMLNode::DOMNamedNodeMap object with the local name and the namespace URI, the SFXXMLElement::SetAttributeNodeNS function will be used.

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::SetAttributeNodeNS | SFXXMLNode::DOMNamedNodeMap | SFXXMLElement::SetAttribute | SFXXMLElement::GetAttribute | SFXXMLElement::GetAttributeNode | SFXXMLElement::GetAttributes | SFXXMLElement::HasAttribute | SFXXMLElement::HasAttributes | SFXXMLElement::RemoveAttribute | SFXXMLElement::RemoveAttributeNode


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

Return value

  • If succeeds: SFERR_NO_ERROR
  • If the newAttr argument is not an Attribute node: SFERR_INVALID_PARAM
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function set the specified Attribute node to the SFXXMLNode::DOMNamedNodeMap object which this node contains internally.

When the Attribute node with the same local name and namespace URI already exists in the SFXXMLNode::DOMNamedNodeMap object, the existing Attribute node will be removed and replaced with the specified Attribute node.

[Note] Note

When the specified Attribute node is searched from the SFXXMLNode::DOMNamedNodeMap object with the name, the SFXXMLElement::SetAttributeNode function will be used.

Reference

SFXXMLElement::SetAttributeNode | SFXXMLNode::DOMNamedNodeMap | SFXXMLElement::SetAttributeNS | SFXXMLElement::GetAttributeNS | SFXXMLElement::GetAttributeNodeNS | SFXXMLElement::GetAttributes | SFXXMLElement::HasAttributeNS | SFXXMLElement::HasAttributes | SFXXMLElement::RemoveAttributeNS