You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by du...@apache.org on 2005/12/27 11:46:33 UTC
svn commit: r359201 -
/webservices/axis/trunk/java/src/org/apache/axis/utils/XMLUtils.java
Author: dug
Date: Tue Dec 27 02:46:30 2005
New Revision: 359201
URL: http://svn.apache.org/viewcvs?rev=359201&view=rev
Log:
Add a util to convert an XML string to a DOM element
Modified:
webservices/axis/trunk/java/src/org/apache/axis/utils/XMLUtils.java
Modified: webservices/axis/trunk/java/src/org/apache/axis/utils/XMLUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/src/org/apache/axis/utils/XMLUtils.java?rev=359201&r1=359200&r2=359201&view=diff
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/utils/XMLUtils.java (original)
+++ webservices/axis/trunk/java/src/org/apache/axis/utils/XMLUtils.java Tue Dec 27 02:46:30 2005
@@ -509,6 +509,7 @@
public static void PrettyDocumentToWriter(Document doc, Writer writer) {
privateElementToWriter(doc.getDocumentElement(), writer, false, true);
}
+
/**
* Convert a simple string to an element with a text node
*
@@ -528,6 +529,22 @@
catch (ParserConfigurationException e) {
// This should not occur
throw new InternalException(e);
+ }
+ }
+
+ /**
+ * Convert an XML string to a DOM element
+ *
+ * @param xml - XML string to convert
+ * @return element - an XML Element, null if no element was created
+ */
+ public static Element StringToElement(String xml) {
+ try {
+ return newDocument(new ByteArrayInputStream(xml.getBytes()))
+ .getDocumentElement();
+ }
+ catch(Exception exp) {
+ throw new RuntimeException(exp);
}
}