java - How to control parsing xml using xStream? -


now using xstream parse object xml-format string. hope when parse xml can want according different fileds, if encounter filed a, add cdata block before it, when encounter filed b, make upper case, this, , here doing now.

public static string textmessagetoxml(responsetextmessage textmsg){     xstream.alias("xml", textmsg.getclass());     return xstream.toxml(textmsg); }    private static xstream xstream = new xstream(new xppdriver() {         @override         public hierarchicalstreamwriter createwriter(writer out) {               return new prettyprintwriter(out) {                   // add cdata block                   boolean cdata = ...;//i need add cdata fields                   boolean isneedupper=...;//only need                  protected void writetext(quickwriter writer, string text) {                       if (cdata) {                           writer.write("<![cdata[");                           writer.write(text);                           writer.write("]]>");                       } else if (isneedupper){                           writer.write(text.touppercase());                       }                       else writer.write(text);                 }               };           }       }); 


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -