ucar.nc2.util.xml
Class Parse

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

public class Parse
extends Object

Miscellaneous XML parsing methods created Jul 3, 2007

Author:
caron

Constructor Summary
Parse()
           
 
Method Summary
static String cleanCharacterData(String text)
          Make sure that text is XML safe
static String quoteXmlContent(String x)
          Replace special characters with entities for XML attributes.
static org.jdom.Element readRootElement(String location)
          Read an XML Document from a URL and return the root element.
static String unquoteXmlContent(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(String location)
                                        throws 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:
IOException - on read error

cleanCharacterData

public static String cleanCharacterData(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 String quoteXmlContent(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 String unquoteXmlContent(String x)
Reverse XML quoting to recover the original string.

Parameters:
x - string to quote
Returns:
equivilent string


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.