GroboUtils

About GroboUtils

Sourceforge
Project

For Developers

GroboUtilXML version 1.1.0

Using Util-XML

Author:Matt Albrecht

All you need to use the XML utility is to:
  1. Add this line to the top of your Java source:
    1:import net.sourceforge.groboutils.util.xml.v1.XMLUtil;
    
  2. 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.
  3. 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.



SourceForge Logo
This space graciously provided by the SourceForge project
Copyright © 2002-2004 GroboUtils Project.
All rights reserved.