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 {
Ïà¹ØÎÊ´ð£º
´ÓÊý¾Ý¿âÖвéѯһÕűíµÄÊý¾Ý
select ²¿ÃÅ,ÐÕÃû from tb
ÈçºÎ²ÅÄÜÉú³ÉÏÂÃæµÄxml¸ñʽ
XML code:
<folder state="unchecked" label="È«²¿">
¡¡¡¡ <folder state="unchecked&qu ......
´ÓÊý¾Ý¿âÖвéѯһÕűíµÄÊý¾Ý
select ²¿ÃÅ,ÐÕÃû from tb
ÈçºÎ²ÅÄÜÉú³ÉÏÂÃæµÄxml¸ñʽÎļþ
<folder state="unchecked" label="È«²¿">
¡¡¡¡<folder state="unchecked" isBra ......
ÎÒÔÚ±àдһ¸öwince5.0µÄ³ÌÐò£¬ÏëʵÏÖ°ÑPDAÉϵÄÒ»¸öLIST <STRING>ÀàÐ͵ÄÊý¾ÝÐòÁл¯ÎªXML£¬È»ºóÔÚPCÉϵÄÒ»¸öwebserviceÄõ½Õâ¸öXML£¬×ª»¯ÎªDataset£¬¸üÐÂPCÉϵÄÊý¾Ý¿â£¬ÎÒÏëÎÊÔõô°ÑXML´«¸øwebserviceµÄÄØ£¿
......
ΪʲôÎҵijÌÐòµ÷ÓÃXMLÅäÖÃÎļþÖеİ¢À²®ÎÄÏÔʾ²»³öÀ´£¿ÆäËûµÄÓïÖÖ¶¼¿ÉÒÔ£¬ÈçÖÐÎÄ£¬Ó¢ÎÄ£¬µÂÎĶ¼¿É¡£
ÎÒ½«XMLµÄ±àÂë¸ÄΪutf-8ºÍunicodeµÄµ½µÃ½á¹û¶¼Ò»Ñù.
°¢À²®ÎĵÄ×Ö¿âÄãÓÐô£¿
ÓÐ,ÎÒµÄEXEÊÇ·ÅÔÚpc»úÉÏÖ´Ðе ......
ÎÒÒªÔÚÍøÒ³ÉÏÉÏ´«Ò»¸öXMLÎļþ£¬ÎÒÔÚC#ÖÐдÁËÒ»¸öÑéÖ¤XMLÎļþ¸ñʽµÄ·½·¨£º
private bool ValidateXml(string xmlFilePath)
{
string xsdPath = Request.PhysicalApp ......