首页 > 解决方案 > 在 XML 开头记录程序结束时间

问题描述

我正在开发 Autodesk Revit 和另一个平台之间的插件,该平台需要从 Revit 导出的 XML 文件,并且此 XML 需要在其开头记录的开始和结束时间。

记录开始时间很容易,但是如何在 XML 的开头记录结束时间?下面的简单例子。

// Some blocks of code here...
string startDateTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffffffK");
xmlWriter.WriteAttributeString("StartDateTime", startDateTime);
xmlWriter.WriteAttributeString("EndDateTime", endDateTime);  //this obviously causes an error as the variable either not defined, initiated or doesn't have the information yet.
// Some more blocks of code here...
string endDateTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffffffK");

标签: c#xmldatetime

解决方案


推荐阅读