Package javax.xml.stream

Examples of javax.xml.stream.XMLEventFactory.createComment()


      XMLEventFactory factory = XMLEventFactory.newInstance();
      Attribute att = factory.createAttribute("some-attribute", "10");
      ArrayList list = new ArrayList();
      list.add(att);
      writer.add(factory.createStartDocument());
      writer.add(factory.createComment("hello"));
      writer.add(factory.createStartElement(new QName("root"), list.iterator(), null));
      writer.close();
      assertEquals("<?xml version='1.0' encoding='UTF-8'?><!--hello--><root some-attribute=\"10\"></root>", stream.toString());
   }
}
View Full Code Here


        while (reader.hasNext()) {
            XMLEvent event = (XMLEvent) reader.next();
            writer.add(event);
            // create a new xml comment with character offset position info
            // (this will be handy when editing the xml document)
            XMLEvent offsetComment = eventFactory.createComment(Integer.toString(event.getLocation()
                    .getCharacterOffset()));
            writer.add(offsetComment);

        }
        writer.close();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.