我需要读取这个日志文件, 这个文件的格式是:
<startedTimestamp>2010-03-02T22:39:55+01:00</startedTimestamp>
<event name="InstallationStarted">2010-03-02T22:39:55+01:00</event>
<event name="IdleCheckPassed">2010-03-02T22:40:05+01:00</event>
<event name="MonitorDeploymentStarted">2010-03-02T22:40:05+01:00</event>
<event name="MonitorDeploymentCompleted">2010-03-02T22:41:20+01:00</event>
<event name="CustomizationPointBeforeTheWholeUpgradeStarted">2010-03-02T22:41:20+01:00</event>
<event name="CustomizationPointBeforeTheWholeUpgradeCompleted">2010-03-02T22:41:20+01:00</event>
<event name="SanityChecksStarted">2010-03-02T22:41:20+01:00</event>
<event name="InstallationFailed">2010-03-02T22:41:27+01:00</event>
<errorMessage>Please attend to pending fuel price changes before attempting an upgrade.</errorMessage>
<stackTrace>Radiant.RPOS.InstallRPOS.Exceptions.InstallationAttemptFailedException: Please attend to pending fuel price changes before attempting an upgrade.
at Radiant.RPOS.InstallRPOS.Engine.ManifestInterpreter.ProcessBuiltinInstallationManifest()
at Radiant.RPOS.InstallRPOS.Engine.InstallRPOS.Main()</stackTrace>
<stoppedTimestamp>2010-03-02T22:41:27+01:00</stoppedTimestamp>
然后将这个日志读取并采用一个格式输出到文本里面,例如:
Example – parsing an <event> node
<event name="InstallationStarted">2010-03-02T22:39:55+01:00</event>
Parses to:
EventType = Event
EventDescription = InstallationStarted
EventTime = 2010-03-02T22:39:55+01:00
Example – parsing an <errorMessage> node
<errorMessage>Please attend to pending fuel price changes before attempting an upgrade.</errorMessage>
Parses to:
EventType = Error
EventDescription = Please attend to pending fuel price changes before attempting an upgrade.
Example – parsing a <startedTimestamp> node
<startedTimestamp>2010-03-02T22:39:55+01:00</startedTimestamp>
Parses to:
EventType = Started
EventTime = 2010-03-02T22:39:55+01:00
我原本是想逐行读取的,但现在按照这个要求是不行了. 希望标准的输入格式:
<Event><InstallationStarted><2010-03-02T22:39:55+01:00>
<Error><Please attend to pending fuel price changes before attempting an upgrade.>
这里不需要考虑<stackTrace>的信息,可以直接跳过不处理.
由于小弟几乎没接触过CMD的程序,而且这次任务又很急,所以想请大家帮忙.
谢谢
<startedTimestamp>2010-03-02T22:39:55+01:00</startedTimestamp>
<event name="InstallationStarted">2010-03-02T22:39:55+01:00</event>
<event name="IdleCheckPassed">2010-03-02T22:40:05+01:00</event>
<event name="MonitorDeploymentStarted">2010-03-02T22:40:05+01:00</event>
<event name="MonitorDeploymentCompleted">2010-03-02T22:41:20+01:00</event>
<event name="CustomizationPointBeforeTheWholeUpgradeStarted">2010-03-02T22:41:20+01:00</event>
<event name="CustomizationPointBeforeTheWholeUpgradeCompleted">2010-03-02T22:41:20+01:00</event>
<event name="SanityChecksStarted">2010-03-02T22:41:20+01:00</event>
<event name="InstallationFailed">2010-03-02T22:41:27+01:00</event>
<errorMessage>Please attend to pending fuel price changes before attempting an upgrade.</errorMessage>
<stackTrace>Radiant.RPOS.InstallRPOS.Exceptions.InstallationAttemptFailedException: Please attend to pending fuel price changes before attempting an upgrade.
at Radiant.RPOS.InstallRPOS.Engine.ManifestInterpreter.ProcessBuiltinInstallationManifest()
at Radiant.RPOS.InstallRPOS.Engine.InstallRPOS.Main()</stackTrace>
<stoppedTimestamp>2010-03-02T22:41:27+01:00</stoppedTimestamp>
然后将这个日志读取并采用一个格式输出到文本里面,例如:
Example – parsing an <event> node
<event name="InstallationStarted">2010-03-02T22:39:55+01:00</event>
Parses to:
EventType = Event
EventDescription = InstallationStarted
EventTime = 2010-03-02T22:39:55+01:00
Example – parsing an <errorMessage> node
<errorMessage>Please attend to pending fuel price changes before attempting an upgrade.</errorMessage>
Parses to:
EventType = Error
EventDescription = Please attend to pending fuel price changes before attempting an upgrade.
Example – parsing a <startedTimestamp> node
<startedTimestamp>2010-03-02T22:39:55+01:00</startedTimestamp>
Parses to:
EventType = Started
EventTime = 2010-03-02T22:39:55+01:00
我原本是想逐行读取的,但现在按照这个要求是不行了. 希望标准的输入格式:
<Event><InstallationStarted><2010-03-02T22:39:55+01:00>
<Error><Please attend to pending fuel price changes before attempting an upgrade.>
这里不需要考虑<stackTrace>的信息,可以直接跳过不处理.
由于小弟几乎没接触过CMD的程序,而且这次任务又很急,所以想请大家帮忙.
谢谢
