如何为xml文件显示正确的时间格式? [英] How to Show correct time format for xml file?

查看:529
本文介绍了如何为xml文件显示正确的时间格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上我使用此代码在xml文件中生成报告...

当报告运行数据和时间以这种格式显示时...这样的日期

2001 -10-26T19:32:52 + 00:00 ,,,,, 2001-10-26T21:32:52 + 02:00 ,,,,而像这样的时间

PT17H41M40S ...... ..我需要正确的standerd格式的日期和时间如果有任何人有一些想法plzzz帮助我是正确的...



  string  xmlPath = Environment.CurrentDirectory.Substring( 0 ,Environment.CurrentDirectory.IndexOf(  bin))+   NewFolder1\\BatchTimeTableRpt.XML; ; 
string xslPath = Environment.CurrentDirectory.Substring( 0 ,Environment.CurrentDirectory.IndexOf(< span class =code-string>
bin))+ NewFolder1\\BatchTimeTableRpt.XSL; ;
string resultPath = Environment.CurrentDirectory.Substring( 0 ,Environment.CurrentDirectory.IndexOf(< span class =code-string> bin))+ NewFolder1\\MyHtml.html; ;
dt.WriteXml(xmlPath);
// XmlReader加载XML文件
XmlReader reader = XmlReader.Create(xmlPath );
// XmlTextWriter创建输出文件
XmlTextWriter writer = new XmlTextWriter(resultPath, null );
// XslCompiledTransform加载XSLT文件
XslCompiledTransform xsl = new XslCompiledTransform();
xsl.Load(xslPath);
xsl.Transform(reader, null ,writer);
// html = result.Document.ToString();
系统。 Diagnostics.Process PROC = new System.Diagnostics.Process();
PROC.StartInfo = new System.Diagnostics.ProcessStartInfo(resultPath);
PROC.Start();

解决方案

嗯。

这是一个正确的标准日期和时间的格式 - 这是一个UCT值: http://www.w3.org/TR/NOTE-datetime [ ^ ]这正是你想要的在xml文件中,可以在多个国家/地区访问,因为它指定时间absolutley而不是默认引用当地时区。



我会留下它单独:xml文件不应被普通人读取! :笑:

Actually i make report in xml file using this code...
when report run data and time appeard in this format... the date like this
2001-10-26T19:32:52+00:00,,,,,2001-10-26T21:32:52+02:00,,,, while Time like this
PT17H41M40S..... i need correct standerd format for date and time how it will be correct if any one has some idea plzzz help me...

string xmlPath = Environment.CurrentDirectory.Substring(0, Environment.CurrentDirectory.IndexOf("bin")) + "NewFolder1\\BatchTimeTableRpt.XML"; ;
string xslPath = Environment.CurrentDirectory.Substring(0, Environment.CurrentDirectory.IndexOf("bin")) + "NewFolder1\\BatchTimeTableRpt.XSL"; ;
string resultPath = Environment.CurrentDirectory.Substring(0, Environment.CurrentDirectory.IndexOf("bin")) + "NewFolder1\\MyHtml.html"; ;
dt.WriteXml(xmlPath);
//XmlReader loads XML file
XmlReader reader = XmlReader.Create(xmlPath);
//XmlTextWriter creats output file
XmlTextWriter writer = new XmlTextWriter(resultPath, null);
//XslCompiledTransform loads XSLT file
XslCompiledTransform xsl = new XslCompiledTransform();
xsl.Load(xslPath);
xsl.Transform(reader, null, writer);
//  html =result.Document.ToString();
System.Diagnostics.Process PROC = new System.Diagnostics.Process();
PROC.StartInfo = new System.Diagnostics.ProcessStartInfo(resultPath);
PROC.Start();

解决方案

Um.
That is a "correct standerd format for date and time" - it's a UCT value: http://www.w3.org/TR/NOTE-datetime[^] and it is exactly what you want in a xml file that can be accessed in multiple countries as it specifies the time absolutley rather than by an implied reference to a local time zone.

I'd leave it alone: xml files aren't supposed to be read by "normal human beings"! :laugh:


这篇关于如何为xml文件显示正确的时间格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆