Package org.dlese.dpc.xml
Class XMLUtils
java.lang.Object
org.dlese.dpc.xml.XMLUtils
This class holds static methods for use in XML processing.
- Author:
- John Weatherley
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final StringEscapes the characters in a String using XML entities.static StringremoveXMLComments(String input) Removes all XML comments from a String.static final StringBufferStrips the XML declaration and DTD declaration from the given XML.static final StringConvert XML to JSON.
-
Constructor Details
-
XMLUtils
public XMLUtils()
-
-
Method Details
-
removeXMLComments
Removes all XML comments from a String.- Parameters:
input- XML String- Returns:
- XML with all comments removed
-
stripXmlDeclaration
Strips the XML declaration and DTD declaration from the given XML. The resulting content is sutable for insertion inside an existing XML element.- Parameters:
rdr- A BufferedReader containing XML.- Returns:
- Content with the XML and DTD declarations stipped out.
- Throws:
IOException- If error
-
xml2json
Convert XML to JSON.- Parameters:
xml- An XML String.- Returns:
- JSON serialization of the XML or empty string if error.
-
escapeXml
Escapes the characters in a String using XML entities.- Parameters:
xml- The String to escape, may be null- Returns:
- A new escaped String, null if null string input
-