XMLѹËõ´«Êä - PowerBuilder / Web Ó¦ÓÃ
¹¦ÄÜ˵Ã÷:Java servlet °ÑXMLÊý¾ÝѹËõºó·¢Ë͵½PBÓû§¶Ë,PBÊÕµ½Êý¾Ýºó½âѹ³öÀ´.
´«ÊäÒª¾¹ýBase64±àÂë.
ÎÊÌâÊÇ:ÄÜÊÕµ½Êý¾Ýµ«Êǽâѹ²»³öÀ´.ÏëÇë½Ì´ó¼Ò»òÕßÓÐʲôºÃµÄ°ì·¨?
PB¿ÉÒÔÓÃ"zlibwapi.DLL" ½âѹ
//////////////////////////////
Java CODE:
//ѹËõÊý¾Ý
if(strXML !=null){
byte[] byte_XMLData=null;
StringZip strZip =new StringZip();
byte_XMLData =StringZip.ZipString(strXML.toString());
String encode = Base64.getEncodedText(byte_XMLData);
//Êä³öÊý¾Ý
PrintWriter outputWriter =null;
try {
outputWriter = res.getWriter();
} catch (IOException e) {
e.printStackTrace();
}
outputWriter.println(encode.toString());
outputWriter.close();
}
package org.peng.util;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
public class StringZip{
/**
* ѹËõ×Ö·û´®Îª byte[]
* ±£´æΪ×Ö·û´®
*
* @param str ѹËõÇ°µÄÎı¾
* @return
*/
public static final byte[] ZipString(String str) {
if(str == null)
return null;
byte[] compressed;
ByteArrayOutputStream out = null;
ZipOutputStream zout = null;
try {
Ïà¹ØÎÊ´ð£º
Êý¾Ý¿â±íÖÐÓÐÒ»ÁУ¨TranXml£©ÀàÐÍÊÇxml£¬´æ´¢µÄÊÇÀàËÆ
<fathernode>
<a>aaa
</a>
<b>bbb
</b>
</fathernode>
µÄÐÅÏ¢£¬²¢ÇÒͨ¹ý²éѯ·½· ......
DataSetµ¼³öxml Åú´¦Àí(Ñ»·)µÃÔõô´¦Àí
XMLÎļþ
<A>
<B>
<C>
</C>
&nb ......
ÄÚÈÝÈçÌâ¡£¡£ÔÚC#Àï¸ÄÈçºÎдÄØ£¿
±¾À´Ë¼Â·ÊÇÏȱȶԽڵãÃû³Æ£¬ÈçÊǵĻ°¾Í±£´æҪɾ³ý½ÚµãµÄϱê·ÅÔÚÊý×éÀȻºóÑ»·É¾³ý£¬µ«·¢ÏÖ¡£¡£µ±ÎÒɾ³ýµÚÒ»¸öºó£¬ËùÓнڵãϱêÊýÁ¿¶¼·¢Éú¸Ä±ä¡£¡£
¾Í²»ÄÜÔÙ°´ÕÕ֮ǰ¼Í¼µÄ½Úµã ......
<UserModel xmlns="http://tempuri.org/">
<Name>Liu</Name>
<Age>23</Age>
</UserModel>
ÔõôÓÃlinq to xml ²éѯ°ÑÉÏÃæµÄÒ»¸ö×Ö·û´® ͶӰ³ÉÒ»¸ ......