XmlReader implements Closeable { public void skipTextContent() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } if (p == PEEKED_ELEMENT_TEXT_CONTENT) { peeked = PEEKED_NONE; long index = source.indexOf(OPENING_XML_ELEMENT); if (index == -1L) { throw syntaxError("Unterminated element text content. Expected </" + pathNames[stackSize - 1] + "> but haven't found"); } buffer.skip(index); } else if (p == PEEKED_CDATA) { peeked = PEEKED_NONE; long index = indexOfClosingCDATA(); buffer.skip(index + 3); } else { throw new XmlDataException("Expected xml element text content but was " + peek() + " at path " + getPath()); } } private  XmlReader(BufferedSource source); static XmlReader of(BufferedSource source); XmlToken peek(); void beginElement(); void endElement(); boolean hasElement(); boolean hasAttribute(); String nextAttributeName(); String nextAttributeValue(); int nextAttributeValueAsInt(); long nextAttributeValueAsLong(); boolean nextAttributeValueAsBoolean(); double nextAttributeValueAsDouble(); void skipAttributeValue(); void skipAttribute(); boolean hasTextContent(); String nextTextContent(); int nextTextContentAsInt(); long nextTextContentAsLong(); double nextTextContentAsDouble(); boolean nextTextContentAsBoolean(); void skipTextContent(); String getPath(); @Override void close(); String nextElementName(); String getCurrentElementName(); void skipRemainingElement();  }
@Test public void skipTextContent() throws IOException { String xml = "<foo>Value</foo>"; XmlReader reader = readerFrom(xml); try { Assert.assertTrue(reader.hasElement()); reader.beginElement(); Assert.assertEquals("foo", reader.nextElementName()); Assert.assertFalse(reader.hasAttribute()); Assert.assertTrue(reader.hasTextContent()); reader.skipTextContent(); reader.endElement(); Assert.assertFalse(reader.hasElement()); Assert.assertEquals(XmlReader.XmlToken.END_OF_DOCUMENT, reader.peek()); } finally { reader.close(); } }