Closed nsyilmaz2 closed 6 years ago
Hello,
We've resolved the issue. Here is the code sample that generates the required xml successfully: ` codeunit 50125 MyCodeunit { trigger OnRun() var t: Text; xmlDoc: XmlDocument; ParentNode: XmlNode; ChildNode: XmlNode; begin xmlDoc := XmlDocument.Create();
//root
AddElementWithPrefix(xmlDoc, 'berat', 'edefter', 'http://www.edefter.gov.tr', ParentNode);
ParentNode.AsXmlElement().Add(XmlAttribute.CreateNamespaceDeclaration('xsi', 'http://www.w3.org/2001/XMLSchema-instance'));
ParentNode.AsXmlElement().Add(XmlAttribute.Create('schemaLocation', 'http://www.w3.org/2001/XMLSchema-instance', 'http://www.edefter.gov.tr ../xsd/edefter.xsd'));
ParentNode.AsXmlElement().Add(XmlAttribute.CreateNamespaceDeclaration('ds', 'http://www.w3.org/2000/09/xmldsig#'));
ParentNode.AsXmlElement().Add(XmlAttribute.CreateNamespaceDeclaration('xades', 'http://uri.etsi.org/01903/v1.3.2#'));
xmlDoc.Add(ParentNode);
//xbrl
AddElementWithPrefix(xmlDoc, 'xbrl', 'xbrli', 'http://www.xbrl.org/2003/instance', ChildNode);
ChildNode.AsXmlElement().Add(XmlAttribute.CreateNamespaceDeclaration('gl-plt', 'http://www.xbrl.org/int/gl/plt/2006-10-25'));
ChildNode.AsXmlElement().Add(XmlAttribute.CreateNamespaceDeclaration('link', 'http://www.xbrl.org/2003/linkbase'));
ChildNode.AsXmlElement().Add(XmlAttribute.CreateNamespaceDeclaration('iso639', 'http://www.xbrl.org/2005/iso639'));
ChildNode.AsXmlElement().Add(XmlAttribute.CreateNamespaceDeclaration('gl-bus', 'http://www.xbrl.org/int/gl/bus/2006-10-25'));
ChildNode.AsXmlElement().Add(XmlAttribute.CreateNamespaceDeclaration('gl-cor', 'http://www.xbrl.org/int/gl/cor/2006-10-25'));
ChildNode.AsXmlElement().Add(XmlAttribute.CreateNamespaceDeclaration('iso4217', 'http://www.xbrl.org/2003/iso4217'));
ChildNode.AsXmlElement().Add(XmlAttribute.CreateNamespaceDeclaration('xlink', 'http://www.w3.org/1999/xlink'));
ParentNode.AsXmlElement().Add(ChildNode);
ParentNode := ChildNode;
//schemaRef
ChildNode := XmlElement.Create('schemaRef', 'http://www.xbrl.org/2003/linkbase').AsXmlNode();
ChildNode.AsXmlElement().Add(XmlAttribute.Create('href', 'http://www.w3.org/1999/xlink', '../xsd/2006-10-25/plt/case-c-b/gl-plt-2006-10-25.xsd'));
ChildNode.AsXmlElement().Add(XmlAttribute.Create('type', 'http://www.w3.org/1999/xlink', 'simple'));
ParentNode.AsXmlElement().Add(ChildNode);
//context
ChildNode := XmlElement.Create('context', 'http://www.xbrl.org/2003/instance').AsXmlNode();
ChildNode.AsXmlElement().Add(XmlAttribute.Create('id', 'ledger_context'));
ParentNode.AsXmlElement().Add(ChildNode);
ParentNode := ChildNode;
ChildNode := XmlElement.Create('entity', 'http://www.xbrl.org/2003/instance').AsXmlNode();
ParentNode.AsXmlElement().Add(ChildNode);
ParentNode := ChildNode;
ChildNode := XmlElement.Create('identifier', 'http://www.xbrl.org/2003/instance', '1234567890').AsXmlNode();
ChildNode.AsXmlElement().Add(XmlAttribute.Create('scheme', 'http://www.gib.gov.tr'));
ParentNode.AsXmlElement().Add(ChildNode);
xmlDoc.WriteTo(t);
Message(t);
end;
procedure AddElementWithPrefix(var pXMLDocument: XmlDocument; pNodeName: Text; pPrefix: Text; pNameSpace: text; var pCreatedNode: XmlNode)
begin
pCreatedNode := XmlElement.Create(pNodeName, pNameSpace).AsXmlNode;
pCreatedNode.AsXmlElement.Add(XmlAttribute.CreateNamespaceDeclaration(pPrefix, pNameSpace));
end;
} ` Thank you,
Ufuk Asci
Since .net is not supported in BC online, is there any other method we can used to create a xml structure by code without using XMLDocument?
Hello @martinhocosta88 ,
In the above examples they are using XmlDocument but not .NET
Regards.
Hello @martinhocosta88 ,
In the above examples they are using XmlDocument but not .NET
Regards.
Thanks for the reply! Just realized that's not .NET. I've checked but it has not the same functions as .NET, like the .Load and .Save
Hello,
We want to create following xml , We tried two method but still getting error. Also we used XmlPort object howewer we were not able to display prefix add to root. How we can fix this problem?
First;
Second;
Thanks.