AnsweredAssumed Answered

Can I read XML file in LISA through java code ?

Question asked by RohanDoshi on Feb 29, 2016
Latest reply on Mar 21, 2016 by DevTestUser

Can I read XML file in LISA through java code ?

I have tried in Eclipse its working fine . But same code not working in LISA .

 

Please suggest , its very urgent for my project .

 

import java.io.File;

import java.text.SimpleDateFormat;

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

 

import org.w3c.dom.Document;

import org.w3c.dom.Element;

import org.w3c.dom.Node;

import org.w3c.dom.NodeList;

       

        StringBuffer strIncorrect = new StringBuffer();

        StringBuffer strCorrect = new StringBuffer();

           SimpleDateFormat dfDate = new SimpleDateFormat("MM/DD/YYYY");

           SimpleDateFormat dfDate1 = new SimpleDateFormat("YYYY-MM-DDTHH24:MI:SS");

       

        try{

        File inputFile = new File ("C:\\Virtualization\\ALCS\\first_force_status.txt");

   

          DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();

       DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();

       Document doc = dBuilder.parse(inputFile);

       doc.getDocumentElement().normalize();

   

       NodeList nList = doc.getElementsByTagName("first_forceStatus");

       for (int temp = 0; temp < nList.getLength(); temp++) {

           Node nNode = nList.item(temp);

           if (nNode.getNodeType() == Node.ELEMENT_NODE) {

               Element eElement = (Element) nNode;

             

              

               String AOI = eElement.getElementsByTagName("AOI").item(0).getTextContent();

               if(AOI.length()<=2000){

                   strCorrect.append("AOI is correct");

                 

               }

               else{

                   strIncorrect.append("AOI is incorrect");

               }

         }

           }

     }

       catch(ParseException e){

           

        }

        if(strIncorrect.length() == 0){

            return strCorrect.toString();

            }

        else{

            return strIncorrect.toString();

            }

Outcomes