KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > atlassian > seraph > util > XMLUtils


1 package com.atlassian.seraph.util;
2
3 import org.w3c.dom.Text JavaDoc;
4 import org.w3c.dom.Element JavaDoc;
5 import org.w3c.dom.Node JavaDoc;
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 JavaDoc getContainedText(Node JavaDoc parent, String JavaDoc childTagName)
17     {
18         try
19         {
20             Node JavaDoc tag = ((Element JavaDoc) parent).getElementsByTagName(childTagName).item(0);
21             String JavaDoc text = ((Text JavaDoc) tag.getFirstChild()).getData();
22             return text;
23         }
24         catch (Exception JavaDoc e)
25         {
26             return null;
27         }
28     }
29 }
30
Popular Tags