【发布时间】:2013-01-25 11:22:20
【问题描述】:
我正在使用带有树的 Jenkins xml api。这是我用于本地托管 Jenkins 服务器的 url。
http://localhost:8080/api/xml?
tree=jobs[name,description,color,healthReport[score,description]]
上面的 url 显示我的 xml 输出为:
<hudson>
<job>
<description/>
<name>build1</name>
<color>disabled</color>
<healthReport>
<description>Build stability: 2 out of the last 5 builds failed.</description>
<score>60</score>
</healthReport>
</job>
<job>
<description>test job description check.</description>
<name>Build2</name>
<color>blue</color>
<healthReport>
<description>Build stability: No recent builds failed.</description>
<score>100</score>
</healthReport>
</job>
<job>
<description/>
<name>Build3</name>
<color>blue</color>
<healthReport>
<description>Build stability: 3 out of the last 4 builds failed.</description>
<score>25</score>
</healthReport>
</job>
</hudson>
现在我想以一种可以进一步处理标签值的方式解析 xml 输出。
例如:
foreach job
if color=blue
print jobname : color
if score = 100
etc
如何在 perl 中做到这一点,我应该使用哪个 perl 模块?
【问题讨论】:
-
XML::Twig(search.cpan.org/~mirod/XML-Twig-3.42/Twig.pm) 会有所帮助。
-
谢谢 Maverick,我是 Perl 的新手,Perl 模块,你能给我指路吗,我怎么能得到这个?
标签: perl xml-parsing jenkins