
We want to create an XML file with :
- a namespace in the first element.
- an XSI prefix for XML elements attributes
Desidered output

<?xml version="1.0" encoding="UTF-8"?>
<FirstElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SecondElement xsi:type="Attribute"/>
</FirstElement>
class temp
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
FileIoPermission permission;
XMLDocument xmlDoc = XMLDocument::newBlank();
XMLNode rootNode;
XMLNode NodeEmpl;
XMLElement xmlElement;
str ns = 'http://www.w3.org/2001/XMLSchema-instance';
permission= new FileIoPermission('C:\\Altitudo\\Test.xml','w');
permission.assert();
xmlDoc = XMLDocument::newBlank();
// Create first node with namespace attribute and xsi
rootNode = xmlDoc.documentElement();
xmlElement = xmlDoc.createElement('FirstElement');
xmlElement.setAttribute('xmlns:xsi',ns);
rootNode = xmlDoc.appendChild(xmlElement);
//Create a sub-node for the "xsi:type" attribute
xmlElement = xmlDoc.createElement('SecondElement');
xmlElement.setAttribute2('type', ns, 'Attribute');
NodeEmpl = rootNode.appendChild(xmlElement);
// Save the file
xmldoc.save('C:\\Altitudo\\test.xml');
}
}