Note that there are some explanatory texts on larger screens.

plurals
  1. POJDOM getChildren() returns empty list
    primarykey
    data
    text
    <p>this is my xml:</p> <p>Example:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF_8" standalone="yes"?&gt; &lt;StoreMessage xmlns="http://www.xxx.com/feed"&gt; &lt;billingDetail&gt; &lt;billingDetailId&gt;987&lt;/billingDetailId&gt; &lt;contextId&gt;0&lt;/contextId&gt; &lt;userId&gt; &lt;pan&gt;F0F8DJH348DJ&lt;/pan&gt; &lt;contractSerialNumber&gt;46446&lt;/contractSerialNumber&gt; &lt;/userId&gt; &lt;declaredVehicleClass&gt;A&lt;/declaredVehicleClass&gt; &lt;/billingDetail&gt; &lt;billingDetail&gt; &lt;billingDetailId&gt;543&lt;/billingDetailId&gt; &lt;contextId&gt;0&lt;/contextId&gt; &lt;userId&gt; &lt;pan&gt;F0F854534534348DJ&lt;/pan&gt; &lt;contractSerialNumber&gt;4666546446&lt;/contractSerialNumber&gt; &lt;/userId&gt; &lt;declaredVehicleClass&gt;C&lt;/declaredVehicleClass&gt; &lt;/billingDetail&gt; &lt;/StoreMessage&gt; </code></pre> <p>With JDOM parser i want to get all <code>&lt;billingDetail&gt;</code> xml nodes from it.</p> <p>my code:</p> <pre><code>SAXBuilder builder = new SAXBuilder(); try { Reader in = new StringReader(xmlAsString); Document document = (Document)builder.build(in); Element rootNode = document.getRootElement(); List&lt;?&gt; list = rootNode.getChildren("billingDetail"); XMLOutputter outp = new XMLOutputter(); outp.setFormat(Format.getCompactFormat()); for (int i = 0; i &lt; 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></pre> <p>but i never get as output xml node as string like:</p> <pre><code>&lt;billingDetail&gt; &lt;billingDetailId&gt;987&lt;/billingDetailId&gt; &lt;contextId&gt;0&lt;/contextId&gt; &lt;userId&gt; &lt;pan&gt;F0F8DJH348DJ&lt;/pan&gt; &lt;contractSerialNumber&gt;46446&lt;/contractSerialNumber&gt; &lt;/userId&gt; &lt;declaredVehicleClass&gt;A&lt;/declaredVehicleClass&gt; &lt;/billingDetail&gt; </code></pre> <p>what i am doing wrong? How can i get this output with JDOM parser? </p> <p>EDIT</p> <p>And why if XML start with</p> <p><code>&lt;StoreMessage&gt;</code> instead like <code>&lt;StoreMessage xmlns="http://www.xxx.com/MediationFeed"&gt;</code></p> <p>then works? How is this possible?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload