[Schmitzm-commits] r1303 - trunk/src/schmitzm/xml

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Nov 24 14:51:23 CET 2010


Author: mojays
Date: 2010-11-24 14:51:22 +0100 (Wed, 24 Nov 2010)
New Revision: 1303

Modified:
   trunk/src/schmitzm/xml/XMLUtil.java
Log:
XMLUtil: new method XMLUtil.getSubChildText(.)

Modified: trunk/src/schmitzm/xml/XMLUtil.java
===================================================================
--- trunk/src/schmitzm/xml/XMLUtil.java	2010-11-23 13:52:52 UTC (rev 1302)
+++ trunk/src/schmitzm/xml/XMLUtil.java	2010-11-24 13:51:22 UTC (rev 1303)
@@ -69,6 +69,23 @@
   
   
   /**
+   * Returns the content of i-th sub-child of an element or {@code null} if the
+   * path can not be tracked because a child does not exist.
+   * @param element an element
+   * @param childName the child names to track
+   */
+  public static String getSubChildText(Element element, String...childName) {
+	  for (int i=0; i<childName.length; i++) {
+		if ( element == null )
+			return null;
+		element = element.getChild(childName[i], element.getNamespace());
+	  }
+	  if ( element == null )
+		  return null;
+	  return element.getTextTrim();
+  }
+
+  /**
    * Returns the i-th sub-child of an element or {@code null} if the
    * path can not be tracked because a child does not exist.
    * @param element an element



More information about the Schmitzm-commits mailing list