hey guys
i have an xml file which looks something like this
Code:
<LMR>
<REPORT ID="1">
<DATE>2004-3-19</DATE>
<CLAIMANT>ABC DEF</CLAIMANT>
<AGE>35</AGE> ......
the attribute "ID" of the tag REPORT gives me the nth record in the xml file. my requirement is to extract the nth record where n is supplied by a query to a mysql database. i have written the following code using JDOM but am unable to compare the attribute value .... ne ideas where i am going wrong ...
Code:
import java.io.IOException;
import java.util.List;
import org.jdom.*;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
public class readXML {
public static void main(String[] args) throws JDOMException, IOException {
SAXBuilder builder = new SAXBuilder();
Document document = builder.build("d:/report.xml");
Document doc = new Document();
Element root = document.getRootElement();
Element ele = new Element ("OUTPUT");
//doc.setRootElement(ele);
List someChild = root.getChildren("REPORT");
System.out.println(someChild.size());
for (int i=0;i<someChild.size(); i++) {
Element temp = (Element) someChild.get(i);
String s = temp.getAttributeValue("ID");
//Attribute a = temp.getAttributeValue();
if (s.trim() == "5") {
List children = temp.getChildren();
}
}
}
}
i cannot get a list of the children of [REPORT ID="5"] .... the if condition is never satisfied
thanks