Example usage for com.liferay.portal.kernel.xml Document remove

List of usage examples for com.liferay.portal.kernel.xml Document remove

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.xml Document remove.

Prototype

public boolean remove(Comment comment);

Source Link

Usage

From source file:com.liferay.dynamic.data.mapping.internal.util.DDMXMLImpl.java

License:Open Source License

@Override
public String getXML(Document document, Fields fields) {
    Element rootElement = null;/*from  w  w  w . j a va2 s  . c  o  m*/

    try {
        if (document != null) {
            rootElement = document.getRootElement();
        } else {
            document = _saxReader.createDocument();

            rootElement = document.addElement("root");
        }

        Iterator<Field> itr = fields.iterator(true);

        while (itr.hasNext()) {
            Field field = itr.next();

            List<Node> nodes = getElementsByName(document, field.getName());

            for (Node node : nodes) {
                document.remove(node);
            }

            appendField(rootElement, field);
        }

        return document.formattedString();
    } catch (IOException ioe) {
        throw new SystemException(ioe);
    }
}