如何在Business Central中加载Xml文件



我在NaV 13中有一个下面的代码,我想在SAAS上的业务中心编写相同的逻辑。

Xmldoc: = xmldoc.xmldocument;xmldoc.load(文件名);

Xmldoc在视觉上是。net变量。我如何在saas上的业务中心编写相同的登录,因为点网变量在saas上不可用。

首先需要将文件内容上传到InStream

您可以使用UploadIntoStream过程完成此操作:

UploadIntoStream('*.xml', XmlInStream);

XmlInStreamInStream型变量。

接下来需要使用新的XML数据类型从流中加载XML文档:

XmlDocument.ReadFrom(XmlInStream, MyXmlDocument);

MyXmlDocumentXmlDocument类型的变量。

然后可以通过MyXmlDocument变量和使用XML数据类型开始处理XML文档。

由于我不知道你具体是如何使用它的,这可能不能直接回答你的问题,但它应该为你指明正确的方向。

这是将XML文件上传到Business Central中的变量的一种方法。关于XmlDocument数据类型的更多信息可以在文档

中找到。
local procedure XMLImportFunction()
var
Ins: InStream;
FileName: Text;
XmlDoc: XmlDocument;
Root: XmlElement;
begin
if UploadIntoStream('Import File', '', '', FileName, InS) then begin
if XmlDocument.ReadFrom(InS, XmlDoc) then begin
XmlDoc.GetRoot(Root);
end;
end;
end;