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?
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> <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>`
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 <
So correct line should be
<testSteps name="Step 1" expected="<b>Γεια σας. ξεκινήστε με τη UPS.</b>" actual="Γεια σας. ξεκινήστε με τη UPS." status="Pass" />
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
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.