PrevNextUpHome SophiaFramework UNIVERSE 5.3

19.5. Creating XML Document

An XML tree is expanded onto memory by using SFXXMLDocument class, and saved to file by using Save function.

19.5.1. Outline

SFXXMLDocument object is the root object of the XML tree.

By using the Create function, a node object is created, and the DOM tree of SFXXMLNode is created and updated.

All the node objects are managed through the root node of the SFXXMLDocument class.

Example 19.1. Basic Processing Flow

SFXXMLElementPtr element=document.CreateElement("new_node");//create new node

document.AppendChild(element);//save at specified position

19.5.2. Create XML Document with Namespace

The SFXXMLDocument::CreateElementNS and SFXXMLDocument::CreateAttributeNS functions are provided for processing namespaces in the SFXXMLDocument class.

In an XML document with namespace, the format of the name of an element or an attribute is divided into Prefix ("prefix") and Local Name ("localname") like [prefix:localname], which is called "Qualified Name".

If an element is created by using the SFXXMLDocument::CreateElementNS function, an attribute of [ xmlns:"prefix"="URI" ] is automatically created.

If the SFXXMLDocument::CreateAttributeNS function is used, the namespace must be set by SFXXMLElement::SetAttribute function.