Class XMLUtils
- java.lang.Object
-
- edu.cornell.mannlib.semservices.util.XMLUtils
-
public class XMLUtils extends Object
Convenience Class to parse XML strings to DOM Document for XML contents retrieval.
-
-
Constructor Summary
Constructors Constructor Description XMLUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voiddisplayNodeInfo(Node node)static DocumentBuildergetDocumentBuilder()static StringgetElementByName(Document document, String name)static NodegetNodeWithXpath(Object obj, String expression)static Documentparse(InputStream stream)static Documentparse(String xmlString)static voidprettyPrint(String xml)static StringprettyPrintToString(String xml)static voidserializeDoc(Document doc)static StringserializeDoctoString(Document doc)static voidserializeNode(Node node)
-
-
-
Field Detail
-
writer
public static Writer writer
-
logger
protected static final org.apache.commons.logging.Log logger
-
-
Method Detail
-
getDocumentBuilder
public static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException
- Throws:
ParserConfigurationException
-
parse
public static Document parse(String xmlString) throws IOException, SAXException, ParserConfigurationException
- Parameters:
xmlString- XML String- Throws:
IOExceptionSAXExceptionParserConfigurationException
-
parse
public static Document parse(InputStream stream) throws IOException, SAXException, ParserConfigurationException
- Parameters:
stream- Input stream- Throws:
IOExceptionSAXExceptionParserConfigurationException
-
getElementByName
public static String getElementByName(Document document, String name)
- Parameters:
document- DOM Documentname- Name
-
serializeDoc
public static void serializeDoc(Document doc) throws IOException
- Parameters:
doc- DOM Document- Throws:
IOException
-
serializeDoctoString
public static String serializeDoctoString(Document doc) throws IOException
- Throws:
IOException
-
prettyPrint
public static void prettyPrint(String xml)
- Parameters:
xml- XML String
-
prettyPrintToString
public static String prettyPrintToString(String xml)
- Parameters:
xml- XML String
-
displayNodeInfo
public static void displayNodeInfo(Node node)
- Parameters:
node- DOM Node
-
serializeNode
public static void serializeNode(Node node) throws IOException
- Parameters:
node- DOM Node- Throws:
IOException
-
-