简体   繁体   中英

How to access the property tag of TEST-result.xml from junit-frames.xsl?

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite errors="0" failures="0" hostname="xxx19" name="MyProject.TestSuite" tests="2" time="105.112" timestamp="2012-04-30T11:32:18">
  <properties>
    <property name="java.vendor" value="Oracle Corporation" />
    <property name="reportstyle" value="." />
    <property name="sun.java.launcher" value="SUN_STANDARD" />    
    <property name="sun.management.compiler" value="HotSpot Client Compiler" />
    <property name="lib" value="C:\Selenium\Selenium JARs" />
    <property name="os.name" value="Windows 7" />   
    <property name="TODAY" value="April 30 2012" />
    <property name="report" value="C:\Selenium-Reports\MyProject-April 30 2012 (17_02_15)" />
    <property name="sun.desktop" value="windows" />
    <property name="java.vm.specification.vendor" value="Oracle Corporation" />
    <property name="ant.home" value="C:\apache-ant-1.8.3" />
    <property name="java.runtime.version" value="1.7.0-ea-b119" />
    <property name="user.name" value="hpadmin" />
    <property name="START_TIME" value="17_02_15" />
</properties>

This is the snippet from my TEST-results.xml

How can I read the following property from the junit-frames.xsl file

property name="report" value="C:\\Selenium-Reports\\MyProject-April 30 2012 (17_02_15)"

Please do the needful.

Thanks in Advance,

-Hanuman

final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

        final Document doc = builder.parse(new File("c://Test.xml"));
        final Element root = doc.getDocumentElement();
        final NodeList list = root.getElementsByTagName("properties");
        for (int i = 0; i < list.getLength(); i++)
        {
            final NodeList propertyList = list.item(i).getChildNodes();
            for (int j = 0; j < propertyList.getLength(); j++)
            {
                final Node property = propertyList.item(j);
                if (property.hasAttributes() && property.getAttributes().item(0).getNodeValue().equals("report"))
                {
                    System.out.println(property.getAttributes().item(1).getNodeValue());
                }

            }

        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM