Java XML Element First getFirstImageTransformElement(final Document doc)

Here you can find the source of getFirstImageTransformElement(final Document doc)

Description

Finds the first Transform Element with an Image child node.

License

Open Source License

Parameter

Parameter Description
doc the section XML Document

Return

the first Transform Element with an Image child node.

Declaration

public static Element getFirstImageTransformElement(final Document doc) 

Method Source Code


//package com.java2s;
//License from project: GNU General Public License 

import org.w3c.dom.*;

public class Main {
    /**/* ww  w.  jav a 2 s .c  o m*/
     * Finds the first Transform Element with an Image child node.
     * @param doc the section XML Document
     * @return the first Transform Element with an Image child node.
     */
    public static Element getFirstImageTransformElement(final Document doc) {
        final NodeList transforms = doc.getElementsByTagName("Transform");
        for (int i = 0; i < transforms.getLength(); ++i) {
            final Element transform = (Element) transforms.item(i);
            final NodeList children = transform.getChildNodes();
            for (int j = 0; j < children.getLength(); ++j) {
                if (children.item(j).getNodeName().equals("Image")) {

                    return transform;
                }
            }
        }
        return null;
    }
}

Related

  1. getFirstElement(String name, Element root)
  2. getFirstElementByTagName(Document doc, String tagName)
  3. getFirstElementByTagName(Document document, String name)
  4. getFirstElementByTagName(Document document, String tag)
  5. getFirstElementText(Document document, String tagName)
  6. getFirstNode(Document doc, String xPathExpression)
  7. getFirstNodeByName(Document d, String s)