Java examples for XML:XML Comment
get XML Comment Node
//package com.java2s; import java.util.ArrayList; import java.util.List; import org.w3c.dom.Comment; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static List<Comment> getCommentNode(Node n) { List<Comment> commentList = new ArrayList<Comment>(); NodeList nodeList = n.getChildNodes(); if (nodeList == null) return null; for (int i = 0; i < nodeList.getLength(); i++) { Node ithNode = nodeList.item(i); if (ithNode instanceof Comment) { commentList.add((Comment) ithNode); }//from ww w . j a v a 2 s. c o m } return commentList; } }