ucar.nc2.util.xml
Class Parse

java.lang.Object
  extended by ucar.nc2.util.xml.Parse

public class Parse
extends java.lang.Object

Miscellaneous XML parsing methods created Jul 3, 2007

Author:
caron

Constructor Summary
Parse()
           
 
Method Summary
static java.lang.String cleanCharacterData(java.lang.String text)
          Make sure that text is XML safe
static java.lang.String quoteXmlContent(java.lang.String x)
          Replace special characters with entities for XML attributes.
static org.jdom.Element readRootElement(java.lang.String location)
          Read an XML Document from a URL and return the root element.
static java.lang.String unquoteXmlContent(java.lang.String x)
          Reverse XML quoting to recover the original string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Parse

public Parse()
Method Detail

readRootElement

public static org.jdom.Element readRootElement(java.lang.String location)
                                        throws java.io.IOException
Read an XML Document from a URL and return the root element.

Parameters:
location - the URL location
Returns:
the root element of the Document
Throws:
java.io.IOException - on read error

cleanCharacterData

public static java.lang.String cleanCharacterData(java.lang.String text)
Make sure that text is XML safe

Parameters:
text - check this
Returns:
original text if ok, else with bad characters removed

quoteXmlContent

public static java.lang.String quoteXmlContent(java.lang.String x)
Replace special characters with entities for XML attributes. special: '&', '<', '>', '\'', '"', '\r', '\n'

Parameters:
x - string to quote
Returns:
equivilent string using entities for any special chars

unquoteXmlContent

public static java.lang.String unquoteXmlContent(java.lang.String x)
Reverse XML quoting to recover the original string.

Parameters:
x - string to quote
Returns:
equivilent string