Hello!
I need to create next XML document :
<?xml version="1.0" encoding="UTF-8"?> <signed xmlns="urn:x-obml:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CMSDETACHED"></signed>
So I create next code:
`xmlDoc := XmlDocument.Create;
xmlDec := xmlDeclaration.Create('1.0','UTF-8','');
xmlDoc.SetDeclaration(xmlDec);
XmlElm := XmlElement.Create('signed');
xmlAtt := XmlAttribute.Create('xmlns', 'urn:x-obml:1.0');
xmlElm.Add(xmlAtt);
xmlAtt := XmlAttribute.Create('xsi', 'xmlns', 'http://www.w3.org/2001/XMLSchema-instance');
xmlElm.Add(xmlAtt);
xmlAtt := XmlAttribute.Create('type', 'xsi', 'CMSDETACHED');
xmlElm.Add(xmlAtt);
xmlDoc.Add(xmlElm);
xmlDoc.WriteTo(XMLText);
exit(XMLText);`
But on xmlDoc.WriteTo(XMLText); row i've got next exception:
The following exception was encountered when processing XML data: 'The prefix '' cannot be redefined from '' to 'urn:x-obml:1.0' within the same start element tag.' at line 0 and position 0.
What's the problem?
Changing to
xmlAtt := XmlAttribute.CreateNamespaceDeclaration('xmlns', 'urn:x-obml:1.0');
goes to exception
Exception of type 'Microsoft.Dynamics.Nav.Types.Exceptions.NavNCLArgumentException' was thrown.
and docs told that
If the prefix is xmlns, then this parameter must be http://www.w3.org/2000/xmlns/; otherwise an exception is thrown.
but i have to have xmlns="urn:x-obml:1.0" because of it's API requirement.
Hello!
I need to create next XML document :
<?xml version="1.0" encoding="UTF-8"?> <signed xmlns="urn:x-obml:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CMSDETACHED"></signed>So I create next code:
But on
xmlDoc.WriteTo(XMLText);row i've got next exception:What's the problem?
Changing to
xmlAtt := XmlAttribute.CreateNamespaceDeclaration('xmlns', 'urn:x-obml:1.0');goes to exception
and docs told that
but i have to have xmlns="urn:x-obml:1.0" because of it's API requirement.