About GroboUtils Sourceforge Project For Developers | GroboUtilXML version
1.1.0 Using Util-XMLAuthor:Matt Albrecht
All you need to use the XML utility is to:
-
Add this line to the top of your Java source:
1:import net.sourceforge.groboutils.util.xml.v1.XMLUtil;
-
To convert a string to an XML-formatted string (suitable for including
in attributes and in-line text):
3:String mystring = XMLUtil.getInstance().utf2xml("Some' < \" < Text &.");
4:StringBuffer sb = new Stringbuffer();
The resulting string will be correctly escaped for XML.
-
If you want to append XML-formatted text to a string buffer, you can use:
4:StringBuffer sb = new Stringbuffer();
5:XMLUtil.getInstance().utf2xml( mytext, sb );
This may be a bit faster, since it doesn't need to perform a
toString() on an internal StringBuffer then append that
to another StringBuffer.
|