¿ìËÙÒµÎñͨµÀ

J2MEѧϰϵÁÐÖ®ÈçºÎ½«J2MEÓëXML¼¯³É - ±à³ÌÈëÃÅÍø

×÷Õß ØýÃû¼¼Êõ À´Ô´ NET±à³Ì ä¯ÀÀ ·¢²¼Ê±¼ä 2012-06-21

J2MEѧϰϵÁÐÖ®ÈçºÎ½«J2MEÓëXML¼¯³É

ʱ¼ä:2011-01-13

1¡¢XML(Extensible Markup Language)¿ÉÀ©Õ¹±ê¼ÇÓïÑÔ??XML¶ÀÁ¢ÓÚÓ²¼þºÍÈí¼þ£¬XMLÎļþºÍHTMLÎļþÒ»Ñù£¬Êµ¼ÊÉÏÊÇÒ»¸öÎı¾Îļþ¡£´´½¨XMLÎļþ×îÆÕͨµÄ¹¤¾ßºÍHTMLÒ»Ñù£¬¾ÍÊÇ“¼Çʱ¾”ÁË¡£³ýÁË“¼Çʱ¾”Ö®Í⣬µ±È»»¹ÓÐһЩ¸ü¼Ó·½±ãµÄ¹¤¾ß£¬ÈçXML Notepad¡¢XML Pro¡¢CLIP¡¢XML SPYµÈ£¬ÕâЩ¹¤¾ßµÄÒ»´óÌصãÊÇ£ºÄܹ»¼ì²éÄãËù½¨Á¢µÄXMLÎļþÊÇ·ñ·ûºÏXML¹æ·¶¡£

2¡¢ÎªÁË·ÃÎÊXMLÎļþ£¬J2ME¹¤¾ßÏä±ØÐë°üº¬Ò»¸öXML·ÖÎö³ÌÐò£¬ÊÊÓÃÓÚÒƶ¯É豸µÄXML·ÖÎö³ÌÐòÓÅÊÆÔÚÓÚ£º²»ÓÃÏûºÄ´óÁ¿µÄÄڴ棨ռÓÃÄÚ´æ½ÏÉÙ£©¡£

3¡¢ÊÊÓÃÓÚÒƶ¯É豸µÄXML·ÖÎö³ÌÐòÓÐÒÔϼ¸ÖÖ£º(XML·ÖÎö³ÌÐòÐèÒª´ÓInternetÉÏÏÂÔØ)

KXML¡¡MinXML¡¡NanoXML¡¡ TinyXML

4¡¢·ÖÎöXMLÎļþÓÐÁ½ÖÖ·½·¨£º»ùÓÚʼþµÄºÍ»ùÓÚÊ÷µÄ¡£

»ùÓÚʼþµÄXML·ÖÎö³ÌÐò??µ¥¶À·ÖÎöXMLÎļþÖеÄÿ¸öÔªËØ£¬²¢Í¨¹ý»Øµ÷·½·¨°Ñ·ÖÎöµÄÊý¾ÝË͵½MIDletÓ¦Óá£

»ùÓÚÊ÷µÄXML·ÖÎö³ÌÐò??Ïà·´¶ÁÈëÕû¸öXMLÎļþµ½Ò»ÖÖÄÚ²¿µÄÊ÷½á¹¹£¬°Ñ´ËÎļþ´æ´¢ÔÚÒƶ¯É豸µÄÄÚ´æÖУ¬È±µãÊÇ´øÀ´É豸ÉϺܴóµÄÄڴ濪Ïú£¬ÓŵãÊÇ¿ì¶ø·½±ãµØµ¼º½ºÍ²Ù×ÝÒÑ·ÖÎöµÄÊý¾Ý¡£

5¡¢Ò»¸öʵÀý??ÓûùÓÚÊ÷µÄXML·ÖÎö³ÌÐòÁ¬½ÓMIDletµ½XMLÎļþ¡£

1)Ê×ÏÈÐèÒªÒ»¸öTinyXML·ÖÎö³ÌÐò,¿É´ÓInternetÉÏÏÂÔØ£¬¸Ã³ÌÐòÊÇÒ»¸ö.jarµÄ°ü£¬Êµ¼ÊÉϾÍÊÇÒ»¸öjavaµÄÀà¿â(ºÜС15KB)¡£

2)ÏÂÔØÍêºó°ÑTinyXML·ÖÎö³ÌÐò·Åµ½X:\WTK104\apps\ProjectName\libÖС£

3)XMLÎļþÄÚÈÝÈçÏ£º

<?xml version="1.0" ?> <mail> <From>Developer</From> <To>Students</To> <Cc>Faculty</Cc> <Date>30 </Date> <Subject>Integration</Subject> <Body Language="English"> This is J2ME!!!!!! </Body> </mail>

Áí´æΪmail.xml,ÄãÒ²¿ÉÒÔʹÓÃ×Ô¼ºµÄXMLÎļþ??°Ñ¸ÃÎļþ·ÅÈçJ2EE·þÎñÆ÷µÄpublic_htmlÎļþ¼ÐÖС£

4)MIDletÓ¦ÓôúÂëÈçÏ£º

import java.io.*; import java.util.*; import java.lang.String; import javax.microedition.lcdui.*; import javax.microedition.io.*; import javax.microedition.midlet.*; //ÏÂÃæÁ½¸ö°ü³öÏÖÔÚXML·ÖÎö³ÌÐòtinyTreeDemoÖÐ import gd.xml.*; import gd.xml.tiny.*; public class tinyTreeDemo extends MIDlet implements CommandListener { private String url; private ParsedXML root; private Display myDisplay=null; private Form mainScreen; private TextField requestField; Command sendCommand=new Command ("SEND",Command.OK,1); public tinyTreeDemo() { //·ÅÖÃmail.xmlÎļþµÄWebÕ¾µã url="http://127.0.0.1:8000/mail.xml"; myDisplay=Display.getDisplay(this); mainScreen=new Form("Type a URL:"); requestField=new TextField (null,url,100,TextField.URL); mainScreen.append(requestField); mainScreen.addCommand(sendCommand); mainScreen.setCommandListener(this); } public void startApp() throws MIDletStateChangeException { myDisplay.setCurrent(mainScreen); ¡¡¡¡¡¡ } ¡¡¡¡¡¡ public void pauseApp() ¡¡¡¡¡¡ { ¡¡¡¡¡¡ } public void destroyApp (boolean unconditional) ¡¡¡¡¡¡ { ¡¡¡¡¡¡ } public void commandAction (Command c,Displayable s) ¡¡¡¡¡¡ { if(c==sendCommand) ¡¡¡¡¡¡¡¡¡¡¡¡¡¡ { String urlString= requestField.getString(); try { //·µ»ØXML¸ùÔªËØ root=TinyParser.parseXML(url); displayNode(root); } catch(ParseException e) { System.err.println("startApp:" + e); } ¡¡¡¡¡¡¡¡

ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»!

·ÖÏíµ½£º ¸ü¶à
Äã¿ÉÄܶÔÏÂÃæµÄÎÄÕ¸ÐÐËȤ

Copyright ©1999-2011 ÏÃÃÅÁèÖڿƼ¼ÓÐÏÞ¹«Ë¾ ÏÃÃÅÓÅͨ»¥Áª¿Æ¼¼¿ª·¢ÓÐÏÞ¹«Ë¾ All rights reserved

µØÖ·(ADD)£ºÏÃÃÅÈí¼þÔ°¶þÆÚÍûº£Â·63ºÅ701E£¨¶«ÄÏÈÚͨÅÔ£© Óʱà(ZIP)£º361008

µç»°£º0592-5908028 ´«Õ棺0592-5908039 ×ÉѯÐÅÏ䣺web@lingzhong.cn ×ÉѯOICQ£º173723134

¡¶ÖлªÈËÃñ¹²ºÍ¹úÔöÖµµçÐÅÒµÎñ¾­ÓªÐí¿ÉÖ¤¡·ÃöB2-20100024  ICP±¸°¸:ÃöICP±¸05037997ºÅ