/** * Note: if the content is another element or set of elements, it returns a string representation * of the hierarchy. */ public static String getTextContent(final Node n) { if (n.hasChildNodes()) { StringBuffer sb = new StringBuffer(); NodeList nl = n.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { sb.append(XMLUtil.elementToString(nl.item(i))); if (i < nl.getLength() - 1) { sb.append('\n'); } } String s = sb.toString(); if (s.length() != 0) { return s; } } return n.getTextContent(); }
boolean hasValidChildren = false; for (int i = 0; i < children.getLength(); i++) { String childToString = XMLUtil.elementToString(children.item(i)); if (!"".equals(childToString)) { sb.append(childToString);
/** * Note: if the content is another element or set of elements, it returns a string representation * of the hierarchy. */ public static String getTextContent(final Node n) { if (n.hasChildNodes()) { StringBuffer sb = new StringBuffer(); NodeList nl = n.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { sb.append(XMLUtil.elementToString(nl.item(i))); if (i < nl.getLength() - 1) { sb.append('\n'); } } String s = sb.toString(); if (s.length() != 0) { return s; } } return n.getTextContent(); }
/** * Note: if the content is another element or set of elements, it returns a string representation * of the hierarchy. */ public static String getTextContent(final Node n) { if (n.hasChildNodes()) { StringBuffer sb = new StringBuffer(); NodeList nl = n.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { sb.append(XMLUtil.elementToString(nl.item(i))); if (i < nl.getLength() - 1) { sb.append('\n'); } } String s = sb.toString(); if (s.length() != 0) { return s; } } return n.getTextContent(); }
/** * Note: if the content is another element or set of elements, it returns a string representation * of the hierarchy. */ public static String getTextContent(final Node n) { if (n.hasChildNodes()) { StringBuffer sb = new StringBuffer(); NodeList nl = n.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { sb.append(XMLUtil.elementToString(nl.item(i))); if (i < nl.getLength() - 1) { sb.append('\n'); } } String s = sb.toString(); if (s.length() != 0) { return s; } } return n.getTextContent(); }
/** * Note: if the content is another element or set of elements, it returns a string representation * of the hierarchy. */ public static String getTextContent(final Node n) { if (n.hasChildNodes()) { StringBuffer sb = new StringBuffer(); NodeList nl = n.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { sb.append(XMLUtil.elementToString(nl.item(i))); if (i < nl.getLength() - 1) { sb.append('\n'); } } String s = sb.toString(); if (s.length() != 0) { return s; } } return n.getTextContent(); }
/** * Note: if the content is another element or set of elements, it returns a string representation * of the hierarchy. */ public static String getTextContent(final Node n) { if (n.hasChildNodes()) { StringBuffer sb = new StringBuffer(); NodeList nl = n.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { sb.append(XMLUtil.elementToString(nl.item(i))); if (i < nl.getLength() - 1) { sb.append('\n'); } } String s = sb.toString(); if (s.length() != 0) { return s; } } return n.getTextContent(); }
/** * Note: if the content is another element or set of elements, it returns a string representation * of the hierarchy. */ public static String getTextContent(final Node n) { if (n.hasChildNodes()) { StringBuffer sb = new StringBuffer(); NodeList nl = n.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { sb.append(XMLUtil.elementToString(nl.item(i))); if (i < nl.getLength() - 1) { sb.append('\n'); } } String s = sb.toString(); if (s.length() != 0) { return s; } } return n.getTextContent(); }
boolean hasValidChildren = false; for (int i = 0; i < children.getLength(); i++) { String childToString = XMLUtil.elementToString(children.item(i)); if (!"".equals(childToString)) { sb.append(childToString);
boolean hasValidChildren = false; for (int i = 0; i < children.getLength(); i++) { String childToString = XMLUtil.elementToString(children.item(i)); if (!"".equals(childToString)) { sb.append(childToString);
boolean hasValidChildren = false; for (int i = 0; i < children.getLength(); i++) { String childToString = XMLUtil.elementToString(children.item(i)); if (!"".equals(childToString)) { sb.append(childToString);
boolean hasValidChildren = false; for (int i = 0; i < children.getLength(); i++) { String childToString = XMLUtil.elementToString(children.item(i)); if (!"".equals(childToString)) { sb.append(childToString);
boolean hasValidChildren = false; for (int i = 0; i < children.getLength(); i++) { String childToString = XMLUtil.elementToString(children.item(i)); if (!"".equals(childToString)) { sb.append(childToString);
boolean hasValidChildren = false; for (int i = 0; i < children.getLength(); i++) { String childToString = XMLUtil.elementToString(children.item(i)); if (!"".equals(childToString)) { sb.append(childToString);
@Test public void testElementToString_4() throws Exception { String s = "<a><![CDATA[somedata]]></a>"; Element e = XMLUtil.stringToElement(s); String tostring = XMLUtil.elementToString(e); Element convertedAgain = XMLUtil.stringToElement(tostring); XMLUtil.assertEquivalent(e, convertedAgain); }
@Test public void testElementToString_2() throws Exception { String s = "<a b=\"something\"></a>"; Element e = XMLUtil.stringToElement(s); String tostring = XMLUtil.elementToString(e); Element convertedAgain = XMLUtil.stringToElement(tostring); XMLUtil.assertEquivalent(e, convertedAgain); }
@Test public void testElementToString_1() throws Exception { String s = "<a b=\"something\">somethingelse</a>"; Element e = XMLUtil.stringToElement(s); String tostring = XMLUtil.elementToString(e); Element convertedAgain = XMLUtil.stringToElement(tostring); XMLUtil.assertEquivalent(e, convertedAgain); }
@Test public void testElementToString_3() throws Exception { String s = "<a b=\"something\"/>"; Element e = XMLUtil.stringToElement(s); String tostring = XMLUtil.elementToString(e); Element convertedAgain = XMLUtil.stringToElement(tostring); XMLUtil.assertEquivalent(e, convertedAgain); }