コード例 #1
0
 /**
  * Gets the first child element of the given node with the specified namespace URI and local name.
  *
  * @param parent the parent node to examine
  * @param namespaceURI the namespace URI of the desired child element; if <code>null</code>, only
  *     elements with a <code>null</code> or empty namespace URI will be considered
  * @param localName the local name of the desired child element
  * @return the corresponding child element, or <code>null</code> if there is no match
  */
 public static Element getElement(Node parent, String namespaceURI, String localName) {
   for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
     if (QNameElementPredicate.evaluate(child, namespaceURI, localName)) {
       return (Element) child;
     }
   }
   return null;
 }
コード例 #2
0
 /**
  * Gets the first child element of the given SOAP element with the specified namespace URI and
  * local name. This overload is necessary as method {@link Node#getNextSibling()} does not behave
  * as expected under some SAAJ implementations.
  *
  * @param parent the parent node to examine
  * @param namespaceURI the namespace URI of the desired child element; if <code>null</code>, only
  *     elements with a <code>null</code> or empty namespace URI will be considered
  * @param localName the local name of the desired child element
  * @return the corresponding child element, or <code>null</code> if there is no match
  */
 public static SOAPElement getElement(SOAPElement parent, String namespaceURI, String localName) {
   Iterator childIt = parent.getChildElements();
   while (childIt.hasNext()) {
     javax.xml.soap.Node child = (javax.xml.soap.Node) childIt.next();
     if (QNameElementPredicate.evaluate(child, namespaceURI, localName)) {
       return (SOAPElement) child;
     }
   }
   return null;
 }