请教诸位大侠一个有关xml的问题,老美限我二十四小时内解决,请大伙多多帮忙提供一个思路啦

zhanguan 2004-11-06 10:20:00
今天中午收到老美的题目,限定在二十四小时内解决,请大伙帮忙啦
题目是
Attached please find two *.txt files. The TestLog.txt is something pulled

from our test tool, and now I want to generate an output file like what you see in

TestResults.txt

Give me brief description on how you attack this problem and possible solutions.


TestLog.txt文件如下:
<?xml version="1.0" encoding="UTF-8" ?>
- <TestLog>
- <LogEvent ID="Computer Start">
- <LogEventProperty Name="Event Type" ID="Event Type">
- <![CDATA[ Computer Start
]]>
</LogEventProperty>
- <LogEventProperty Name="Start Date" ID="Start Date">
- <![CDATA[ 01/08/2003
]]>
</LogEventProperty>
- <LogEventProperty Name="Start Time" ID="Start Time">
- <![CDATA[ 10:23:25
]]>
</LogEventProperty>
+ <LogEventProperty Name="End Date" ID="End Date">
- <![CDATA[ 01/08/2003
]]>
</LogEventProperty>
- <LogEventProperty Name="End Time" ID="End Time">
- <![CDATA[ 10:23:25
]]>
</LogEventProperty>
- <LogEventProperty Name="Result" ID="Result">
- <![CDATA[ Fail
]]>
</LogEventProperty>
- <LogEventProperty Name="Failure Reason" ID="Failure Reason">
- <![CDATA[
]]>
</LogEventProperty>
<LogEventProperty Name="Failure Description" ID="Failure Description" />
- <LogEventProperty Name="Error File" ID="Error File">
- <![CDATA[ e000
]]>
</LogEventProperty>
- <LogEventProperty Name="Output File" ID="Output File">
- <![CDATA[ o000
]]>
</LogEventProperty>
- <LogEventProperty Name="Operating System" ID="Operating System">
- <![CDATA[ Windows
]]>
</LogEventProperty>
- <LogEventProperty Name="OS Version" ID="OS Version">
- <![CDATA[ XP
]]>
</LogEventProperty>
- <LogEventProperty Name="Processor" ID="Processor">
- <![CDATA[ Pentium
]]>
</LogEventProperty>
- <LogEventProperty Name="Display Resolution" ID="Display Resolution">
- <![CDATA[ 1024x768
]]>
。。。。。。
后面还有一长串



TestResults.txt文件如下:


Event Type Result Date & Time Computer Name
===================================================================================================
Computer Start Fail 1/8/2003 10:23:25 AM PHYLLISC11147
Script Start Fail 1/8/2003 10:23:25 AM PHYLLISC11147
Verification Point (Object Data) Pass 1/8/2003 10:23:28 AM PHYLLISC11147
Verification Point (Region Image) Fail 1/08/2003 10:24:00 AM PHYLLISC11147
Script End Fail 1/08/2003 10:24:00 AM PHYLLISC11147
Computer End Fail 1/08/2003 10:24:00 AM PHYLLISC11147

...全文
157 12 打赏 收藏 举报
写回复
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
春哥视角 2004-11-07
  • 打赏
  • 举报
回复
我测试用的TestLog.txt

<?xml version="1.0" encoding="UTF-8" ?>
<TestLog>
<LogEvent ID="Computer Start">
<LogEventProperty Name="Event Type" ID="Event Type">
<![CDATA[ Computer Start
]]>
</LogEventProperty>
<LogEventProperty Name="Start Date" ID="Start Date">
<![CDATA[ 01/08/2003
]]>
</LogEventProperty>
<LogEventProperty Name="Start Time" ID="Start Time">
<![CDATA[ 10:23:25
]]>
</LogEventProperty>
<LogEventProperty Name="End Date" ID="End Date">
<![CDATA[ 01/08/2003
]]>
</LogEventProperty>
<LogEventProperty Name="End Time" ID="End Time">
<![CDATA[ 10:23:25
]]>
</LogEventProperty>
<LogEventProperty Name="Result" ID="Result">
<![CDATA[ Fail
]]>
</LogEventProperty>
<LogEventProperty Name="Failure Reason" ID="Failure Reason">
<![CDATA[
]]>
</LogEventProperty>
<LogEventProperty Name="Failure Description" ID="Failure Description" />
<LogEventProperty Name="Error File" ID="Error File">
<![CDATA[ e000
]]>
</LogEventProperty>
<LogEventProperty Name="Output File" ID="Output File">
<![CDATA[ o000
]]>
</LogEventProperty>
<LogEventProperty Name="Operating System" ID="Operating System">
<![CDATA[ Windows
]]>
</LogEventProperty>
<LogEventProperty Name="OS Version" ID="OS Version">
<![CDATA[ XP
]]>
</LogEventProperty>
<LogEventProperty Name="Processor" ID="Processor">
<![CDATA[ Pentium
]]>
</LogEventProperty>
<LogEventProperty Name="Display Resolution" ID="Display Resolution">
<![CDATA[ 1024x768
]]>
</LogEventProperty>
<LogEventProperty Name="Computer Name" ID="Computer Name">
<![CDATA[ PHYLLISC11147
]]>
</LogEventProperty>
</LogEvent>
</TestLog>
春哥视角 2004-11-07
  • 打赏
  • 举报
回复
Sorry

建立xxx.xsl文件,内容

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<table border="0" >
<tr>
<th>Event Type</th>
<th>Result</th>
<th><![CDATA[Date & Time]]></th>
<th>Computer Name</th>
</tr>
<tr>
<td colspan="4">===================================================================================================</td>
</tr>
<xsl:for-each select="TestLog/LogEvent">
<tr>
<td><xsl:value-of select = "LogEventProperty[0]"/></td>
<td><xsl:value-of select = "LogEventProperty[5]"/></td>
<td><xsl:value-of select = "LogEventProperty[1]"/><xsl:value-of select = "LogEventProperty[2]"/></td>
<td><xsl:value-of select = "LogEventProperty[14]"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

再建立showlog.htm

<html>
<body>
<script language="javascript">
// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("TestLog.txt")
// Load the XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("xxx.xsl")
// Transform
document.write(xml.transformNode(xsl))
</script>
</body>
</html>

再把testLog.txt拷到同一目录下
运行showlog.htm

由于你贴上的testLog文件不全,找不到 Computer Name在哪里,现假设为在Display Resolution后面
是是非非 2004-11-07
  • 打赏
  • 举报
回复
偶的MSN:gegeTerminator@hotmail.com
是是非非 2004-11-07
  • 打赏
  • 举报
回复
用XSLT

楼主把源文件Mail到webmaster@i-love-mm.com
偶试试
flyskytoday 2004-11-07
  • 打赏
  • 举报
回复
这个要用到xml的dom(document object model)解析...
就是有一个xml文件,然后再有html(中有javascript解析或VBScript解析)文件就可以了

以你上面所说的一个xml文件和解析成下面的格式并不难呀
zhanguan 2004-11-07
  • 打赏
  • 举报
回复
老大们,写代码肯定是来不及了,只要一个思路向boss汇报就可以交差了,不知道老大们对xml熟悉吗
zhanguan 2004-11-07
  • 打赏
  • 举报
回复
还有两个小时,期望救星出现:)
zhanguan 2004-11-07
  • 打赏
  • 举报
回复
boss只是要我一个解题的思路,随便什么语言实现都可以,不用管那个testing tool天可怜见,我昨晚才开始学xml,今天中午一点之前就必须交卷:((,这位好心人,你有什么解题思路吗,我的qq是94771,msn是zhanguan@hotmail.com,多谢了
梅雪香 2004-11-07
  • 打赏
  • 举报
回复
英文不好,不知道理解的对不对
老板跟你要一个写日志文件和运行结果文件的解决方案,样式就是上面的样式
是用js写吗?应该不是吧,还有要求里说的那个test tool是什么东西
测试的程序是后台还是前台的程序?
春哥视角 2004-11-07
  • 打赏
  • 举报
回复
有这点时间看一下教程足够了,小哥
flyskytoday 2004-11-07
  • 打赏
  • 举报
回复
好长啊...英文又不明白,,,,

爱莫能助啊:)
zhanguan 2004-11-07
  • 打赏
  • 举报
回复
有哪位大侠可以帮帮忙吗
发帖
JavaScript

8.7w+

社区成员

Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
帖子事件
创建了帖子
2004-11-06 10:20
社区公告
暂无公告