org.xerial.util.xml.dom
Class DOMUtil

java.lang.Object
  extended by org.xerial.util.xml.dom.DOMUtil

public class DOMUtil
extends Object

DOMを操作する際に役立つユーティリティ

Author:
leo

Method Summary
static String getText(Element element)
          Gets the text data enclosed by the specified element.
static String getTextContent(Element parentElement, String tagName)
          TagのElementから、特定の子ノードのtext contentを返す
static HashMap<String,String> getTextContentMap(Element element)
           
static HashMap<String,String> getTextContentMap(InputStream xmlStream)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTextContent

public static String getTextContent(Element parentElement,
                                    String tagName)
TagのElementから、特定の子ノードのtext contentを返す

Parameters:
parentElement -
tagName -
Returns:
tagNameの子ノードのtext content

getText

public static String getText(Element element)
Gets the text data enclosed by the specified element. If xml data has several separated text data, the returned text will be their concatination. For example, in the following XML data, getText(Element) for the wiki element gives " Hello World! Nice to meet you.".
  
   Hello World!
   leo
   Nice to meet you.
 
 
The result removes ignorable white spaces between tags.

Parameters:
element - the target element
Returns:
the text content of the element, or null if no text content is found under the element

getTextContentMap

public static HashMap<String,String> getTextContentMap(InputStream xmlStream)
                                                throws XMLException,
                                                       IOException
Throws:
XMLException
IOException

getTextContentMap

public static HashMap<String,String> getTextContentMap(Element element)
Parameters:
element - 探索を開始するElementノード
Returns:
Relative Path Expression -> Text Content の構造のHashMap


Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.1 Japan License.