String () { if (myContent.length == 0) { return ""; } // If we hold only a Text or CDATA, return it directly if (myContent.length == 1) { Content obj = myContent[0]; return obj instanceof Text ? ((Text)obj).getText() : ""; } // Else build String up StringBuilder textContent = new StringBuilder(); boolean hasText = false; for (Content content : myContent) { if (content instanceof Text) { textContent.append(((Text)content).getText()); hasText = true; } } return hasText ? textContent.toString() : ""; }