在axis2中,字符串怎么能转化为OMElement呢?

解决方案 »

  1.   

    public  static OMElement toOMElement(String xmlStr, String encoding) {
        OMElement xmlValue;
        try {
          xmlValue = new StAXOMBuilder(new ByteArrayInputStream(xmlStr
              .getBytes(encoding))).getDocumentElement();
          return xmlValue;
        } catch (Exception e) {
          return null;
        }
      }其中参数xmlStr 字符串 例如<ppp>aaa</ppp>  encoding 字符编码 例如utf-8