@Test public void test2() throws XMLStreamException { StringReader input = new StringReader("<alice><bob>charlie</bob></alice>"); StringWriter output = new StringWriter(); XMLEventReader reader = XMLInputFactory.newFactory().createXMLEventReader(input); XMLOutputFactory factory = new JsonXMLOutputFactory(); factory.setProperty(JsonXMLOutputFactory.PROP_MULTIPLE_PI, true); XMLEventWriter writer = factory.createXMLEventWriter(output); writer = new XMLMultipleEventWriter(writer, false, "/bob"); writer.add(reader); writer.close(); Assert.assertEquals("{\"alice\":{\"bob\":[\"charlie\"]}}", output.toString()); }
@Override public void add(XMLEventReader reader) throws XMLStreamException { while (reader.hasNext()) { add(reader.nextEvent()); } }
XMLMultipleEventWriter extends EventWriterDelegate { @Override public void add(XMLEventReader reader) throws XMLStreamException { while (reader.hasNext()) { add(reader.nextEvent()); } } }
XMLMultipleEventWriter extends EventWriterDelegate { @Override public void add(XMLEventReader reader) throws XMLStreamException { while (reader.hasNext()) { add(reader.nextEvent()); } } XMLMultipleEventWriter(XMLEventWriter parent, boolean matchRoot, String... multiplePaths); }
XMLMultipleEventWriter extends EventWriterDelegate { @Override public void add(XMLEventReader reader) throws XMLStreamException { while (reader.hasNext()) { add(reader.nextEvent()); } } XMLMultipleEventWriter(XMLEventWriter parent, boolean matchRoot, String... multiplePaths); @Override void setParent(XMLEventWriter parent); void addMultiplePath(String path); @Override void add(XMLEventReader reader); @Override void add(XMLEvent event); }
XMLMultipleEventWriter extends EventWriterDelegate { @Override public void add(XMLEventReader reader) throws XMLStreamException { while (reader.hasNext()) { add(reader.nextEvent()); } } XMLMultipleEventWriter(XMLEventWriter parent, boolean matchRoot, String... multiplePaths); @Override void setParent(XMLEventWriter parent); void addMultiplePath(String path); @Override void add(XMLEventReader reader); @Override void add(XMLEvent event);  }