1 package com.atlassian.seraph.util;
2
3 import org.w3c.dom.Text;
4 import org.w3c.dom.Element;
5 import org.w3c.dom.Node;
6
7 /**
8 * Some basic XML utility methods used by Seraph.
9 */
10 public class XMLUtils
11 {
12 /**
13 * With a given parent XML Element, find the text contents of the child element with
14 * supplied name.
15 */
16 public static String getContainedText(Node parent, String childTagName)
17 {
18 try
19 {
20 Node tag = ((Element) parent).getElementsByTagName(childTagName).item(0);
21 String text = ((Text) tag.getFirstChild()).getData();
22 return text;
23 }
24 catch (Exception e)
25 {
26 return null;
27 }
28 }
29 }