Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>i had the same problem and i did this:<br> i made 2 functions, getxml() checks if there are child nodes<br> and xmltagswtf() returns the rest of code</p> <pre><code>public String getxml(Node b){ String va = ""; if (b.hasChildNodes()==true){ int nodes = 0; int a=b.getChildNodes().getLength(); while (nodes &lt;a){ Node c = b.getChildNodes().item(nodes); if(c.getNodeName()!="#text"){ va+="&lt;"+c.getNodeName()+"&gt;"+getxml(c)+"&lt;/"+c.getNodeName()+"&gt;"; }else{ va+=getxml(c); }nodes+=1; } }else{va=b.getTextContent();} return va; } public String xmltagswtf(String xmlt, String what) throws SAXException, IOException, ParserConfigurationException{ InputStream is = new ByteArrayInputStream(xmlt.getBytes("UTF-8")); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document document = documentBuilder.parse(is); NodeList response = document.getElementsByTagName(what); Node nod = response.item(0); String nodos = ""; if (nod.hasChildNodes()==true){ int nodes = 0; int a=nod.getChildNodes().getLength(); while (nodes &lt;a){ Node c = nod.getChildNodes().item(nodes); nodos+="&lt;"+c.getNodeName()+"&gt;"+getxml(c)+"&lt;/"+c.getNodeName()+"&gt;"; nodes+=1; } }else{ nodos+=nod.getTextContent(); System.out.println(nodos); } return nodos; } </code></pre> <p>then do something like this: </p> <pre><code>String xml ="&lt;hello&gt;&lt;hai&gt;welcome&lt;/hai&gt;&lt;/hello&gt;"; String hai =xmltagswtf(xml, "hello"); </code></pre>
    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.
    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