Ò»¸ö¼òµ¥µÄXML for J2ME
×÷Õߣºwuhua
¿Õ¼ä£ºhtt://wuhua.3geye.net
תÔØÇë±£ÁôÉÏÃæµÄÐÅÏ¢£¨Çë×ðÖØ֪ʶ²úÆ·£©Ð»Ð»
ÏàÐÅ´ó¼Ò¶¼ÓùýKxmlµÄ¶«Î÷ÁË£¬²»¹ý¸öÈ˸оõkxml»¹ÊÇ´óÁËЩ¡£ÏÖÔÚ½éÉÜÒ»¸ö±Èkxml¸ú¼ò½éµÄxmlµÄÀà¡£¶ÔÓÚһЩСÏîÄ¿£¬»òÕ߶Ôxml½âÊÍÒªÇó²»ÊǺܸߵÄÏîÄ¿À´ËµÈ´ÊǸö²»´íµÄÑ¡Ôñ¡£
ÏÂÃæ¿´¿´ÄÇ´úÂëÓëDemo°É¡£
Java´úÂë
package org.gggeye.easymf.xml;
import java.util.Enumeration;
import java.util.Vector;
/**
*
* @author wuhua
* <a href="http://wuhua.3geye.net">ÎҵIJ©¿Í</a>
*
*/
public class XMLParser {
private XMLNode root=null;
private XMLNode exeNode=null;
private int offset=0;
private String xml="";
private int xmlLength=0;
private String version="1.1";
private String encoding="UTF-8";
public XMLParser(String xml){
this.xml=xml;
this.xmlLength=xml.length();
}
public char getNextCharacter(){
char rt= xml.charAt(offset);
offset++;
return rt;
}
/**
Ïà¹ØÎĵµ£º
5. ÃüÃû¹æÔò£¨²»ÄÜ°üÀ¨ xml£¬¿Õ¸ñ£¬¼âÀ¨ºÅ£¬µÈÌØÊâ·ûºÅ£¬²»ÄÜÊý×Ö¿ªÍ·£©
6. ¿ÉÒÔ×Ô´øÊôÐÔ¡£ÊôÐÔÖµÓÓ”±êʾ
7. ×¢ÊÍ<!--×¢Ê͵ÄÄÚÈÝ-->
8. Èç¹ûÒªÏÔʾÌØÊâ·ûºÅ¿ÉÓÃ<![CDATA[ ÕâÀïдÌØÊâ·ûºÅ ]]>
´´½¨
var xml:XML=<shuiGuo>
& ......
1£©
XMLÊÇÒ»ÏîÈÈÃŵļ¼Êõ¡£ËüÖ®ËùÒÔÄܹ»ÒýÆðÈËÃǵÄÐËȤ£¬Ò»¸öÖ÷ÒªµÄÔÒòÔÚÓÚËüÊ®·ÖµÄ¼òµ¥£¬ÈËÃÇ¿ÉÒÔºÜÈÝÒ×µØÀí½âºÍʹÓÃËü¡£Ã¿Ò»¸ö³ÌÐòÔ±¶¼ÄÜÇáÒ׵ؿ´¶®Ò»¸öXMLÎļþ£¬Àí½âËü°üº¬µÄÄÚÈÝ¡£
.NETÖаüº¬Á˺ܶàÖ§³ÖXMLµÄÀ࣬ÕâЩÀàʹµÃ³ÌÐòԱʹÓÃXML±à³Ì¾ÍÈçͬÀí½âXMLÎļþÒ»Ñù¼òµ¥¡£ÔÚÕâƪÎÄÕÂÖУ¬ÎÒ½«¸ø³öÕâÑùµÄÒ»¸öÀàµÄʹÓÃʾ ......
ÂòÁËÕ½Õù»úÆ÷2£¬Ð´Íê½Ì³Ì×¼±¸É±µ½Ë¯¾õ£¬ÏÖÔÚÏÈ×öµÚÒ»²½£¬Ð´½Ì³Ì¡£AIRµÄÎļþ²Ù×÷²»ÄÑ£¬¿´Íê½Ì³ÌÓ¦¸Ã¿ÉÒÔÂú×ãÄã¶ÔÎļþµÄËùÓлù±¾²Ù×÷¡£Õâƪ½Ì³ÌÖ÷ÒªÒÔʵ¼Ê²Ù×÷ÖÐÓöµ½µÄÇé¿öÀ´½²½â
ÎÒÃÇÏëÏëÎļþ²Ù×÷¶¼»áÓÐʲôÄÚÈÝ£¬ÎÞ·ÇÊÇ´´½¨£¬Ð޸ģ¬É¾³ý£¬Òƶ¯£¬¿½±´¡£ÔÚÕâ¸ö¹ý³ÌÖÐÎÒÃÇ»áÉæ¼°µ½Ò»Ð©ÖܱߵIJÙ×÷£¬±ÈÈçÎļþ¼Ð£¬ÎļþÑ¡ÔñÆ÷£¬ÎÄ ......
1.Èç¹ûÐèÒªÔÚÓ¦ÓóÌÐòÖд¦ÀíxmlÊý¾Ý£¬Ê×ÏÈÒª´´½¨1¸öXmlDocument¶ÔÏó£¬È»ºóͨ¹ýload·½·¨´ÓxmlÊý¾ÝÔ´ÖмÓÔضÔÏó¡£
2.xmlÖеÄÊý¾ÝÖ÷Òª±íÏÖΪԪËغÍÊôÐÔÁ½ÖÖÐÎʽ¡£
3.¶ÁÈ¡ÔªËØ
¶ÁÈ¡ÔªËØ¿Éͨ¹ýij½ÚµãµÄChildNodesÊôÐÔ»ñÈ¡Æä×ӽڵ㼯ºÏ£¬È»ºó¸ù¾Ý½ÚµãµÄNodeTypeÊôÐÔÈ·¶¨´Ë½ÚµãÊÇ·ñÊôÓÚÔªËؽڵ㡣ԪËؽڵãµÄÃû³Æ¿Éͨ¹ýNameÊôÐÔ» ......
Ç°ÑÔ
XMLÔ½À´Ô½ÈÈ£¬¹ØÓÚXMLµÄ»ù´¡½Ì³ÌÍøÂçÉ ......