How to modify values of a XML in J2ME?

后端 未结 1 836
广开言路
广开言路 2021-01-27 01:29

Suppose there is a XML in my J2ME application :



   
      

        
1条回答
  •  耶瑟儿~
    2021-01-27 02:00

    For you XML sample you could write a class like:

    
        class Client {
            String id;
            String name;
            String email;
        }
    
    

    And unmarshall your XML to it. I have shared a way of doing this with SAX from JSR 172 at http://smallandadaptive.blogspot.com.br/2010/11/xml-data-binding.html.

    To marshall your class back to XML you can create a method like:

    
        String toXML() {
            StringBuffer sb = new StringBuffer();
    
            sb.append("");
            sb.append("").append(name).append("");
            sb.append("").append(email).append("");
            sb.append("");
    
            return sb.toString();
        }
    
    

    0 讨论(0)
提交回复
热议问题