SophiaFramework UNIVERSE 5.3 |
#include <SFXXMLDocument.hpp>
class SFXXMLDocument : public SFXXMLNode;
SFMTYPEDEFCLASS(SFXXMLDocument)
A Document node(SFXXMLDocument) contains a document of the XML document.
Note | |
---|---|
The Document node is the root node of the DOM tree |
Note | |
---|---|
The functions for creating the DOM nodes such as SFXXMLDocument::CreateTextNode and SFXXMLDocument::CreateElement cannot be used only in the Document node(SFXXMLDocument). |
SFXXMLNode | SFXXMLAttribute | SFXXMLCDATASection | SFXXMLComment | SFXXMLDocumentFragment | SFXXMLDocumentType | SFXXMLElement | SFXXMLEntity | SFXXMLEntityReference | SFXXMLNotation | SFXXMLProcessingInstruction | SFXXMLText
Constructor/Destructor |
---|
SFXXMLDocument( Void ) Constructor of the SFXXMLDocument class.
|
~SFXXMLDocument( Void ) Destructor of the SFXXMLDocument 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.
|
SFXXMLAttributePtr |
CreateAttribute(
SFXAnsiStringConstRef name
, SFXAnsiStringConstRef value
) Create an Attribute node.
|
SFXXMLAttributePtr |
CreateAttributeNS(
SFXAnsiStringConstRef name
, SFXAnsiStringConstRef namespaceURI
) Create an Attribute node with qualified name and namespace URI.
|
SFXXMLCDATASectionPtr |
CreateCDATASection(
SFXAnsiStringConstRef data
) Create a CDATASection node.
|
SFXXMLCommentPtr |
CreateComment(
SFXAnsiStringConstRef data
) Create a Comment node.
|
SFXXMLDocumentFragmentPtr |
CreateDocumentFragment( Void ) Create an empty DocumentFragment node.
|
SFXXMLDocumentTypePtr |
CreateDocumentType(
SFXAnsiStringConstRef name
, SFXAnsiStringConstRef publicId
, SFXAnsiStringConstRef systemId
) Create an empty DocumentType node.
|
SFXXMLElementPtr |
CreateElement(
SFXAnsiStringConstRef name
) Create an Element node.
|
SFXXMLElementPtr |
CreateElementNS(
SFXAnsiStringConstRef name
, SFXAnsiStringConstRef namespaceURI
) Create an Element node with qualified name and namespace URI.
|
SFXXMLEntityPtr |
CreateEntity(
SFXAnsiStringConstRef name
) Create an Entity node.
|
SFXXMLEntityReferencePtr |
CreateEntityReference(
SFXAnsiStringConstRef name
) Create an EntityReference node.
|
SFXXMLNotationPtr |
CreateNotation(
SFXAnsiStringConstRef name
) Create a Notation node.
|
SFXXMLProcessingInstructionPtr |
CreateProcessingInstruction(
SFXAnsiStringConstRef target
, SFXAnsiStringConstRef data
) Create a Processing Instruction node.
|
SFXXMLTextPtr |
CreateTextNode(
SFXAnsiStringConstRef data
) Create a Text node.
|
DOMNodeListPtr |
GetChildNodes( Void ) Get all the child nodes.
|
SFXXMLElementPtr |
GetDocumentElement( Void ) Get the root node of the DOM tree.
|
SFXXMLDocumentTypePtr |
GetDocumentType( Void ) Get the DocumentType node.
|
DOMNodeListPtr |
GetElementsByTagName(
SFXAnsiStringConstRef tag
, SFXXMLNodeConstPtr root = null
) Get all the Element nodes that match the specified tag name.
|
DOMNodeListPtr |
GetElementsByTagNameNS(
SFXAnsiStringConstRef localname
, SFXAnsiStringConstRef namespaceURI
, SFXXMLNodeConstPtr root = null
) Get all the Element nodes that match the specified local name and namespace URI.
|
ACharConstPtr |
GetEncoding( Void ) Get the encoding.
|
SFXXMLNodePtr |
GetFirstChild( Void ) Get the first child node.
|
SFXXMLNodePtr |
GetLastChild( Void ) Get the last child node.
|
DOMNodeListPtr |
GetListsByTypeFilter(
NodeType type
) Get all the nodes that match the specified node type.
|
ACharConstPtr |
GetNodeName( Void ) Get the node name.
|
NodeType |
GetNodeType( Void ) Get the node type.
|
Bool |
GetStandalone( Void ) Check whether Standalone is set or not.
|
ACharConstPtr |
GetVersion( Void ) Get the version number.
|
Bool |
HasChildNodes( Void ) Check whether this node has any child nodes or not.
|
SFCError |
InsertBefore(
SFXXMLNodeConstPtr newchild
, SFXXMLNodeConstPtr refchild
) Insert the specified 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.
|
SFCError |
Save(
SFXAnsiStringConstRef output
, Bool indent = true
) Save the document to file.
|
SFCError |
Save(
SFXPathConstRef output
, Bool indent = true
) Save the document to file.
|
SFCError |
Save(
SFXOutputStreamRef output
, Bool indent = true
) Save the document to file.
|
Void |
SetDocumentType(
SFXXMLDocumentTypeConstPtr doctype
) Set the DocumentType node.
|
Void |
SetEncoding(
SFXAnsiStringConstRef encoding
) Set the encoding.
|
Void |
SetStandalone(
Bool standalone
) Set the Standalone attribute.
|
Void |
SetVersion(
SFXAnsiStringConstRef version
) Set the version number.
|
Bool |
EqualNode(
SFXXMLNodeConstPtr arg
)
(inherits from SFXXMLNode)
Check whether this node equals the specified node or not.
|
SFXXMLNodePtr |
GetNextSibling( Void )
(inherits from SFXXMLNode)
Get the next sibling node.
|
ACharConstPtr |
GetNodeValue( Void )
(inherits from SFXXMLNode)
Get the node value.
|
SFXXMLNodePtr |
GetParentNode( Void )
(inherits from SFXXMLNode)
Get the parent node.
|
SFXXMLNodePtr |
GetPreviousSibling( Void )
(inherits from SFXXMLNode)
Get the previous sibling node.
|
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 )
|
[ public, explicit ] SFXXMLDocument(Void);
[ public, virtual ] virtual ~SFXXMLDocument(Void);
[ public, virtual ] SFCError AppendChild( SFXXMLNodeConstPtr newchild // child node to append );
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.
[ 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 );
Specify the target node where to copy this node.
If true is set to this argument, copy the child nodes recursively.
Otherwise, copy only this node.
[ public ] SFXXMLAttributePtr CreateAttribute( SFXAnsiStringConstRef name // attribute name SFXAnsiStringConstRef value // attribute value );
Return the Attribute node (SFXXMLAttribute), or return null.
The SFXXMLDocument::CreateAttributeNS function is used to create an Attribute node with qualified name and namespace URI
The SFXXMLElement::SetAttributeNode or SFXXMLElement::SetAttribute function is used to set an Attribute node(SFXXMLAttribute) to an Element node(SFXXMLElement).
// create Attribute node (set attribute value) SFXXMLAttributePtr atti = document.CreateAt tribute("ISBN", "4-7741-1616-5"); // set Attribute node to Element node book->SetAttributeNode(atti);
SFXXMLElement::SetAttributeNode | SFXXMLElement::SetAttribute | SFXXMLDocument::CreateAttributeNS | SFXXMLAttribute | SFXXMLElement | SFXXMLNode
[ public ] SFXXMLAttributePtr CreateAttributeNS( SFXAnsiStringConstRef name // qualified name of attribute SFXAnsiStringConstRef namespaceURI // namespace URI of attribute );
Return the Attribute node ( SFXXMLAttribute ), or return null.
// create Attribute node with qualified name and namespace URI SFXXMLAttributePtr atti = document.CreateAttributeNS("book:isbn","http://www.w3.org/book"); // set Attribute value atti->SetValue("4-7741-1616-5"); // set Attribute node to Element node book->SetAttributeNode(atti);
SFXXMLElement::SetAttributeNode | SFXXMLElement::SetAttribute | SFXXMLDocument::CreateAttribute | SFXXMLAttribute | SFXXMLElement | SFXXMLNode
[ public ] SFXXMLCDATASectionPtr CreateCDATASection( SFXAnsiStringConstRef data // data of CDATASection to set );
Return the CDATASection node(SFXXMLCDATASection), or return null.
Create the CDATASection node of <![CDATA[<AUTHOR age="5">Sophia Cradle</AUTHOR>]]>.
// create CDATASection node book->SetAttributeNode(atti); SFXXMLCDATASectionPtr cdata = document.CreateCDATASection("<AUTHOR age=\"5\">Sophia Cradle</AUTHOR>"); // set CDATASection node book->SetAttributeNode(atti); boot->AppendChild(SFXXMLNodePtr(cdata));
[ public ] SFXXMLCommentPtr CreateComment( SFXAnsiStringConstRef data // data of comment to set );
Return the Comment node (SFXXMLComment), or return null.
Create the Comment node that contains "this a test code!".
// create Comment node SFXXMLCommentPtr cdata = document.CreateComment("this a test code!"); // add Comment node boot->AppendChild(SFXXMLNodePtr(cdata));
[ public ] SFXXMLDocumentFragmentPtr CreateDocumentFragment(Void);
Return the DocumentFragment node (SFXXMLDocumentFragment), or return null.
[ public ] SFXXMLDocumentTypePtr CreateDocumentType( SFXAnsiStringConstRef name // qualified name of the document type SFXAnsiStringConstRef publicId // public identifier of external subset SFXAnsiStringConstRef systemId // system identifier of external subset );
Return the DocumentType node (SFXXMLDocumentType), or return null.
Create the DocumentType node of <!DOCTYPE boot PUBLIC "public-boot.dtd">.
// create DocumentType node SFXXMLDocumentTypePtr doctype = document.CreateDocumentType("boot","public-boot.dtd","); // add DocumentType node document.AppendChild(SFXXMLNodePtr(doctype));
[ public ] SFXXMLElementPtr CreateElement( SFXAnsiStringConstRef name // name of the element );
Return the Element node (SFXXMLElement), or return null.
The SFXXMLDocument::CreateElementNS function is used to create Element node with qualified name and namespace URI.
SFXXMLDocument::CreateElementNS | SFXXMLElement | SFXXMLNode
[ public ] SFXXMLElementPtr CreateElementNS( SFXAnsiStringConstRef name // qualified name of the element SFXAnsiStringConstRef namespaceURI // namespace URI of the element );
Return the Element node (SFXXMLElement), or return null.
Create <xsd:node xmlns:xsd="http://www.w3.org/xsd">node element</xsd:node> Element node
// create Element node with qualified name and namespace URI specified ( URI = http://www.w3.org/xsd ) SFXXMLElementPtr element = document.CreateElementNS("xsd:node", "http://www.w3.org/xsd"); // set the text to Element node element->SetText("node element"); // add Element node boot->AppendChild(element);
[ public ] SFXXMLEntityPtr CreateEntity( SFXAnsiStringConstRef name // entity name );
Return the Entity node (SFXXMLEntity), or return null.
Add the created Entity node to the DocumentType node using the SFXXMLDocument::AppendChild function, etc.
Create the Entity node of <!ENTITY copyright "Copyright 2007, Sophia. All rights reserved">.
// create Entity node SFXXMLEntityPtr entity = document.CreateEntity("copyright \"Copyright 2007, Sophia. All rights reserved\""); // add Entity node to DocumentType node doctype->GetEntities()->SetNamedItem(entity);
[ public ] SFXXMLEntityReferencePtr CreateEntityReference( SFXAnsiStringConstRef name // name of entity reference );
Return the EntityReference node (SFXXMLEntityReference), or return null.
Create the EntityReference node of "copyright".
// create EntityReference node SFXXMLEntityReferencePtr entityref = document.CreateEntityReference("copyright"); // add EntityReference node boot->AppendChild(SFXXMLNodePtr(entityref));
SFXXMLDocument::CreateEntity | SFXXMLEntityReference | SFXXMLNode
[ public ] SFXXMLNotationPtr CreateNotation( SFXAnsiStringConstRef name // name of the Notation node );
Return the Notation node (SFXXMLNotation), or return null.
The created Notation node is set to the DocumentType node. The SFXXMLDocument::AppendChild function cannot be used for the Notation node.
Create the Notation node of <!NOTATION XLS PUBLIC "http://www.microsoft.com/office/excel/">.
// create Notation node SFXXMLNotationPtr notation = document.CreateNotation("XLS"); // set PUBLIC identifier notation->SetPublicID("http://www.microsoft.com/office/excel/"); // set Notation node doctype->GetNotations()->SetNamedItem(notation);
[ public ] SFXXMLProcessingInstructionPtr CreateProcessingInstruction( SFXAnsiStringConstRef target // target of processing Instruction SFXAnsiStringConstRef data // content of processing Instruction );
Return the ProcessingInstruction node (SFXXMLProcessingInstruction), or return null.
Create the ProcessingInstruction node of <?xml-stylesheet type="text/xsl" href="viewer.xsl"?>.
// create ProcessingInstruction node SFXXMLProcessingInstructionPtr pi = document.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"viewer.xsl\"); // append ProcessingInstruction node document.AppendChild(pi);
[ public ] SFXXMLTextPtr CreateTextNode( SFXAnsiStringConstRef data // text to set );
Return the Text node (SFXXMLText), or return null.
// create Text node, and then append it
element->AppendChild(SFXXMLNodePtr(document.CreateTextNode("New text node")));
[ public, virtual, const ] DOMNodeListPtr GetChildNodes(Void);
Return the pointer to the SFXXMLNode::DOMNodeList instance that contains all child nodes of this node.
Note | |
---|---|
Each element of SFXXMLNode::DOMNodeList is of the "pointer to the SFXXMLNode" type. |
SFXXMLNode::DOMNodeList | SFXXMLNode::GetChildNodes | SFXXMLNode
[ public, const ] SFXXMLElementPtr GetDocumentElement(Void);
// get root node of DOM tree
SFXXMLElementPtr root = document.GetDocumentElement();
[ public, const ] SFXXMLDocumentTypePtr GetDocumentType(Void);
SFXXMLDocument::SetDocumentType | SFXXMLDocumentType | SFXXMLNode
[ public, const ] DOMNodeListPtr GetElementsByTagName( SFXAnsiStringConstRef tag // tag name: QName can be specified if namespace is set SFXXMLNodeConstPtr root = null // root node to search from );
Specify the tag name. Capital letters and small letters are distinguished. QName can be specified if namespace is set.
If null is set, return a list of the Element nodes with the specified tag name for entire document.
If a node is set, return a list of the Element nodes with the specified tag name in the desendant nodes of this node.
All the Element nodes with the specified tag name are returned as the pointer to the SFXXMLNode::DOMNodeList instance.
All the Element nodes with the specified tag name are stored in the SFXXMLNode::DOMNodeList instance.
Note | |
---|---|
When namespace is set, QName(i.e., "namespace prefix:local name") can be specified as a tag name. |
Note | |
---|---|
When the local name and the namespace URI are specified, the SFXXMLDocument::GetElementsByTagNameNS function will be used. |
Note | |
---|---|
The SFXXMLElement::GetElementsByTagName function internally calls this function by specifying the root argument. |
Note | |
---|---|
To get the nodes of the specific node type, use the SFXXMLDocument::GetListsByTypeFilter function. |
SFXXMLDocument::GetElementsByTagNameNS | SFXXMLElement::GetElementsByTagName | SFXXMLNode::DOMNodeList | SFXXMLDocument::GetListsByTypeFilter | SFXXMLElement | SFXXMLNode
[ public, const ] DOMNodeListPtr GetElementsByTagNameNS( SFXAnsiStringConstRef localname // local name of the element SFXAnsiStringConstRef namespaceURI // namespace URI of the element SFXXMLNodeConstPtr root = null // root node to search from );
Specify the local name of the element. Capital letters and small letters are distinguished.
Specify the namespace URI of the element.
If null is set, return a list of the Element nodes with the specified local name and namespace URI for entire document.
If a node is set, return a list of the Element nodes with the specified local name and namespace URI in the desendant nodes of this node.
All the Element nodes with the specified local name and namespace URI are returned as the pointer to the SFXXMLNode::DOMNodeList instance.
All the Element nodes with the specified local name and namespace URI are stored in the SFXXMLNode::DOMNodeList instance.
Note | |
---|---|
When the tag name is specified, the SFXXMLDocument::GetElementsByTagName function will be used. |
Note | |
---|---|
The SFXXMLElement::GetElementsByTagNameNS function internally calls this function by specifying the root argument. |
Note | |
---|---|
To get the nodes of the specific node type, use the SFXXMLDocument::GetListsByTypeFilter function. |
SFXXMLDocument::GetElementsByTagName | SFXXMLElement::GetElementsByTagNameNS | SFXXMLNode::DOMNodeList | SFXXMLDocument::GetListsByTypeFilter | SFXXMLElement | SFXXMLNode
[ public, const ] ACharConstPtr GetEncoding(Void);
Return null if the encoding is not set.
[ public, virtual, const ] SFXXMLNodePtr GetFirstChild(Void);
Return the first child node of this node. Return null if this node has no child.
SFXXMLDOMParser parser; // DOM Parser SFXXMLDocumentPtr root = parser.GetDocument(); // get root node SFXXMLNodePtr child = root->GetFirstChild(); // get first child of root node
[ public, virtual, const ] SFXXMLNodePtr GetLastChild(Void);
Return the last child node of this node. Return null if this node has no child.
[ public, const ] DOMNodeListPtr GetListsByTypeFilter( NodeType type // node type );
Return all the nodes(DOMNodeList type) that match the specified node type.
All the nodes of the specified node type are stored in the SFXXMLNode::DOMNodeList instance. For example, if the "type argument" is specified with COMMENT_NODE, then all the Comment nodes are returned.
To get the Element nodes with the specific tag name, use the SFXXMLDocument::GetElementsByTagName function.
// get all nodes that are ELEMENT_NODE SFXXMLNode::DOMNodeListPtr list = root->GetListsByTypeFilter(ELEMENT_NODE); if (list) { // get each node SFXXMLNode::DOMNodeList::Enumerator iter = list->GetFirstEnumerator(); while (iter.HasNext()) { SFXXMLNodePtr child = iter.GetNext(); if(child->GetNodeType() == SFXXMLNode::ELEMENT_NODE); ... } }
[ public, virtual, const ] ACharConstPtr GetNodeName(Void);
Return the "#document" string.
[ public, virtual, const ] NodeType GetNodeType(Void);
Return DOCUMENT_NODE.
[ public, const ] Bool GetStandalone(Void);
[ public, const ] ACharConstPtr GetVersion(Void);
[ public, virtual, const ] Bool HasChildNodes(Void);
[ public, virtual ] SFCError InsertBefore( SFXXMLNodeConstPtr newchild // node to insert SFXXMLNodeConstPtr refchild // newchild node is inserted before refchild node );
[ public, virtual ] SFCError RemoveChild( SFXXMLNodeConstPtr oldchild // child node to remove );
[ public, virtual ] SFCError ReplaceChild( SFXXMLNodeConstPtr newchild // new child node to replace with SFXXMLNodeConstPtr oldchild // old child node to be replaced );
[ public ] SFCError Save( SFXAnsiStringConstRef output // file name Bool indent = true // whether indented or not );
[ public ] SFCError Save( SFXPathConstRef output // file path Bool indent = true // whether indented or not );
[ public ] SFCError Save( SFXOutputStreamRef output // output stream Bool indent = true // whether indented or not );
By default, application home directory is set to file path.
[ public ] Void SetDocumentType( SFXXMLDocumentTypeConstPtr doctype // DocumentType node );
[ public ] Void SetEncoding( SFXAnsiStringConstRef encoding // the encoding to set );
[ public ] Void SetVersion( SFXAnsiStringConstRef version // version number );
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |