Java XML Node Next getNextComment(Node element)

Here you can find the source of getNextComment(Node element)

Description

get Next Comment

License

Open Source License

Declaration

public static String getNextComment(Node element) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2006-2010 eBay Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *******************************************************************************/

import org.w3c.dom.Node;

public class Main {
    public static String getNextComment(Node element) {
        while (element.getNextSibling() != null) {
            Node prev = element.getNextSibling();
            if (prev.getNodeType() == Node.COMMENT_NODE) {
                return prev.getTextContent();
            } else if (prev.getNodeType() == Node.TEXT_NODE) {
                return getNextComment(prev);
            } else if (prev.getNodeType() == Node.ELEMENT_NODE) {
                return null;
            }/*from w w w  . jav a  2s.  co  m*/
        }
        return null;
    }
}

Related

  1. getNext(final Node current, final boolean sameName)
  2. getNext(Node current)
  3. getNext(Node current, String name, int type)
  4. getNext(Node node)
  5. getNextComment(Node element)
  6. getNextElement(Node el)
  7. getNextElement(Node node)
  8. getNextElement(Node node)
  9. getNextElement(Node node)