JDOM getChildren() returns empty list

Rajakbsnl

New Member
this is my xml:Example:\[code\]<?xml version="1.0" encoding="UTF_8" standalone="yes"?><StoreMessage xmlns="http://www.xxx.com/feed"> <billingDetail> <billingDetailId>987</billingDetailId> <contextId>0</contextId> <userId> <pan>F0F8DJH348DJ</pan> <contractSerialNumber>46446</contractSerialNumber> </userId> <declaredVehicleClass>A</declaredVehicleClass> </billingDetail> <billingDetail> <billingDetailId>543</billingDetailId> <contextId>0</contextId> <userId> <pan>F0F854534534348DJ</pan> <contractSerialNumber>4666546446</contractSerialNumber> </userId> <declaredVehicleClass>C</declaredVehicleClass> </billingDetail></StoreMessage>\[/code\]With JDOM parser i want to get all \[code\]<billingDetail>\[/code\] xml nodes from it.my code:\[code\]SAXBuilder builder = new SAXBuilder();try { Reader in = new StringReader(xmlAsString); Document document = (Document)builder.build(in); Element rootNode = document.getRootElement(); List<?> list = rootNode.getChildren("billingDetail"); XMLOutputter outp = new XMLOutputter(); outp.setFormat(Format.getCompactFormat()); for (int i = 0; i < list.size(); i++) { Element node = (Element)list.get(i); StringWriter sw = new StringWriter(); outp.output(node.getContent(), sw); StringBuffer sb = sw.getBuffer(); String text = sb.toString(); xmlRecords.add(sb.toString()); }} catch (IOException io) { io.printStackTrace();} catch (JDOMException jdomex) { jdomex.printStackTrace();}\[/code\]but i never get as output xml node as string like:\[code\]<billingDetail> <billingDetailId>987</billingDetailId> <contextId>0</contextId> <userId> <pan>F0F8DJH348DJ</pan> <contractSerialNumber>46446</contractSerialNumber> </userId> <declaredVehicleClass>A</declaredVehicleClass></billingDetail>\[/code\]what i am doing wrong? How can i get this output with JDOM parser? EDITAnd why if XML start with\[code\]<StoreMessage>\[/code\] instead like \[code\]<StoreMessage xmlns="http://www.xxx.com/MediationFeed">\[/code\]then works? How is this possible?
 
Back
Top