0

I am trying to parse an xml file for the attributes:

Testcase: name & status

testSteps: expected, actual, & status

but I'm getting this error:

[Fatal Error] xmltestdata.xml:4:1635: The value of attribute "expected" associated with an element type "testSteps" must not contain the '<' character.

What is the reason I would be getting this error?

Java

private static JiraIssue parseXML(String xmlFile) {
    try {

        //Read the XML File 
        File xmlFile1 = new File(xmlFile);
        DocumentBuilderFactory dbFactory
        DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(xmlFile1);

        doc.getDocumentElement().normalize();

        System.out.println("Root element :" + 
        doc.getDocumentElement().getNodeName());


    }

    finally {
    return null;

    }
}

XML (Sorry about the poor formatting)

<xml>
  <testSuite name="Suite: Test Reporter" startTime="05/22/2017 14:07:57" endTime="05/22/2017 14:07:57">

    <!-- name would have the (1) MSA ticket and (2) test status-->

    <testCase name="MSA001|en|us" status="Pass">

      <!-- below could be the (3) comment-->

      <testSteps name="Step 1" expected="Γεια σας. ξεκινήστε με τη UPS." actual="Γεια σας. ξεκινήστε με τη UPS." status="Pass" />
      <testSteps name="Step 2" expected="Αποστολή" actual="Αποστολή" status="Pass" />                     </testCase>

    <testCase name="MSA002|en|ca" status="Fail">


      <testSteps name="Step 1" expected="Bonjour. Démarrez avec UPS." actual="Bonjour. Démarrez avec UPS." status="Pass" />
      <testSteps name="Step 2" expected="Bonjour. Démarrez avec UPS." actual="Not found" status="Fail" />                     </testCase>

    <testCase name="MSA003|en|fr" status="Skip">

      <testSteps name="Step 1" expected="Dobrý den. začněte využívat služby UPS." actual="Αποστολή" status="Fail" />
      <testSteps name="Step 3" expected="Dobrý den. začněte využívat služby UPS." actual="Dobrý den. začněte využívat služby UPS." status="Pass" />                     </testCase>

    <testCase name="MSA004|en|ls" status="Fail">


      <testSteps name="Step 1" expected="Dobrý den. začněte využívat služby UPS." actual="Αποστολή" status="Fail" />
      <testSteps name="Step 2" expected="Dobrý den. začněte využívat služby UPS." actual="Dobrý den. začněte využívat služby UPS." status="Pass" />                     </testCase>

    <testCase name="MSA005|en|us" status="Fail">

      <testSteps name="Step 1" expected="<b>Γεια σας. ξεκινήστε με τη UPS.</b>" actual="Γεια σας. ξεκινήστε με τη UPS." status="Pass" />
      <testSteps name="Step 2" expected="Αποστολή" actual="Αποστολή" status="Fail" />                     </testCase>
  </testSuite>
</xml>`

1
  • The XML is badly formatted <testSteps name="Step 1" expected="<b>Γεια σας. ξεκινήστε με τη UPS.</b>" actual="Γεια σας. ξεκινήστε με τη UPS." status="Pass" /> - the <b> and </b> are invalid Commented May 22, 2017 at 22:23

2 Answers 2

3

Error is here:

     <testSteps name="Step 1" expected="<b>Γεια σας. ξεκινήστε με τη UPS.</b>" actual="Γεια σας. ξεκινήστε με τη UPS." status="Pass" />

You cannot have < in attribute value; it should be replaced with &lt;

So correct line should be

<testSteps name="Step 1" expected="&lt;b>Γεια σας. ξεκινήστε με τη UPS.&lt;/b>" actual="Γεια σας. ξεκινήστε με τη UPS." status="Pass" />
Sign up to request clarification or add additional context in comments.

Comments

-1

You may get problem about encoding. Let's try to set encoding (I don't know what is your language in this xml, please try to find your encoding and set). A reference to set encoding

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.