org.jmage.util
Class XmlUtil

java.lang.Object
  extended by org.jmage.util.XmlUtil

public class XmlUtil
extends java.lang.Object

Xml util class


Constructor Summary
XmlUtil()
           
 
Method Summary
 java.lang.String getAttribute(org.w3c.dom.Node node, java.lang.String key)
          Gets an attribute's value in an xml dom node
 org.w3c.dom.Node getNamedChildNode(org.w3c.dom.Node parentNode, java.lang.String nodeName)
          Gets a named child node under a parent node.
 org.w3c.dom.Document read(java.io.File file)
          Read an xml document from file.
 org.w3c.dom.Document read(java.io.InputStream inputStream)
          Read an xml document from input stream.
 void setAttribute(org.w3c.dom.Node node, java.lang.String key, java.lang.String value)
          Sets an attribute in an xml dom node
 void write(org.w3c.dom.Document document, java.io.File destFile)
          Writes an xml dom document to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlUtil

public XmlUtil()
Method Detail

write

public void write(org.w3c.dom.Document document,
                  java.io.File destFile)
           throws java.io.IOException
Writes an xml dom document to a file.

Parameters:
document -
destFile -
Throws:
java.io.IOException

read

public org.w3c.dom.Document read(java.io.File file)
                          throws java.io.IOException,
                                 org.xml.sax.SAXException,
                                 javax.xml.parsers.ParserConfigurationException
Read an xml document from file.

Parameters:
file - the file
Returns:
the xml document
Throws:
java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

read

public org.w3c.dom.Document read(java.io.InputStream inputStream)
                          throws java.io.IOException,
                                 org.xml.sax.SAXException,
                                 javax.xml.parsers.ParserConfigurationException
Read an xml document from input stream.

Parameters:
inputStream - the input stream.
Returns:
the xml document
Throws:
java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

setAttribute

public void setAttribute(org.w3c.dom.Node node,
                         java.lang.String key,
                         java.lang.String value)
Sets an attribute in an xml dom node

Parameters:
node - the node
key - the attribute's name
value - the attribute's value

getNamedChildNode

public org.w3c.dom.Node getNamedChildNode(org.w3c.dom.Node parentNode,
                                          java.lang.String nodeName)
                                   throws java.util.NoSuchElementException
Gets a named child node under a parent node. If multiple nodes with that name exist, method will return the first matching node.

Parameters:
parentNode -
nodeName -
Returns:
the child node
Throws:
java.util.NoSuchElementException

getAttribute

public java.lang.String getAttribute(org.w3c.dom.Node node,
                                     java.lang.String key)
                              throws javax.naming.directory.NoSuchAttributeException
Gets an attribute's value in an xml dom node

Parameters:
node - the node
key - the attribute's name
Returns:
the attribute's value
Throws:
javax.naming.directory.NoSuchAttributeException


Copyright © 2004-2008 Sourceforge. All Rights Reserved.