XMLÖлسµµÄÎÊÌâ - Web ¿ª·¢ / XML/SOAP
´ó¼ÒÇë¿´£¬Õâ¸öÊÇÎÒдµÄÉú³ÉxmlµÄ·½·¨£¬ÓõÄÊÇjdom,ÇëÎÊÈçºÎ¿ÉÒÔʹÉú³ÉµÄxmlÖеĶÎÂäÀï´ø¡°»Ø³µ¡±£¿£¿£¿
public void bulidprotocolxml(String textarea)throws IOException, JDOMException {
Element root, e1;
Document Doc;
root = new Element("protocol_");
Doc = new Document(root);
//µÚÒ»¸öprotocol½áµã¼°×Ó½áµã
e1 = new Element("protocol");
e1.setAttribute("id","01");
Element e11 = new Element("content");
e11.setText(textarea);
e1.addContent(e11);
root.addContent(e1);
XMLOutputter XMLOut = new XMLOutputter();
Format format = Format.getCompactFormat();
format.setIndent(" "); //ÔÚÔªËØºó»»ÐУ¬Ã¿Ò»²ãÔªËØËõÅÅÁ½¸ñ
format.setEncoding("gb2312"); //ÉèÖÃ×Ö·û±àÂë
XMLOut.setFormat(format); //É趨¸ñʽ
XMLOut.output(Doc, new FileOutputStream(/test.xml));
}
Ã²ËÆ²»Ðа¡ÅóÓÑ
{{
Ïà¹ØÎÊ´ð£º
ΪʲôÎҵijÌÐòµ÷ÓÃXMLÅäÖÃÎļþÖеİ¢À²®ÎÄÏÔʾ²»³öÀ´£¿ÆäËûµÄÓïÖÖ¶¼¿ÉÒÔ£¬ÈçÖÐÎÄ£¬Ó¢ÎÄ£¬µÂÎͼ¿É¡£
ÎÒ½«XMLµÄ±àÂë¸ÄΪutf-8ºÍunicodeµÄµ½µÃ½á¹û¶¼Ò»Ñù.
°¢À²®ÎĵÄ×Ö¿âÄãÓÐô£¿
ÓÐ,ÎÒµÄEXEÊÇ·ÅÔÚpc»úÉÏÖ´Ðе ......
XMLÎļþÄÚÈÝ£º
- <ResList>
<page>0</page>
- <resItem>
<resName>WWW</resName>
</resItem>
- <resItem>
&nb ......
¹¦ÄÜ˵Ã÷:Java servlet °ÑXMLÊý¾ÝѹËõºó·¢Ë͵½PBÓû§¶Ë,PBÊÕµ½Êý¾Ýºó½âѹ³öÀ´.
´«ÊäÒª¾¹ýBase64±àÂë.
ÎÊÌâÊÇ:ÄÜÊÕµ½Êý¾Ýµ«Êǽâѹ²»³öÀ´.ÏëÇë½Ì´ó¼Ò»òÕßÓÐʲôºÃµÄ°ì·¨?
PB¿ÉÒÔÓÃ"zlibwapi.DLL" ½âѹ
......
ÓÃSAX½âÎöXMLÖУ¬Ê¹ÓÃÕâ¶Î´úÂë
String feed="http://www.google.com/ig/api?weather="+strCity;
URL url = new URL(feed.replace(" ", "%20"));
......
<?xml version="1.0" encoding="utf-8" ?>
<HuiSin>
<admin>100,100</admin>
<user>200,200</user>
ÔõÑùÔÚÕâÀïÌí¼ÓÒ»¸öеÄÄØ£¿
< ......