private ClassLoader xmlLoader = Thread.currentThread().getContextClassLoader();
private void parseXML(String resource){
resource = StringUtils.substring(resource,resource.indexOf(":")+1,resource.length());
InputStream inputStream = xmlLoader.getResourceAsStream(resource);
SAXReader reader;
Document doc;
try {
reader = new SAXReader();
doc = reader.read(inputStream);
Element rootElement = doc.getRootElement();
List<Element> subElements = rootElement.elements();
for(Element message : subElements){
putMessageTypeAndTask(message.attributeValue("type"),parseTasks(message));
}
} catch (DocumentException e) {
e.printStackTrace();
}
} ......
Java codeFormat ft=Format.getRawFormat();
ft.setEncoding("utf-8");
ft.setIndent(" ");//ÉèÖÃËõ½ø
XMLOutputter outputter=new XMLOutputter(ft);//ÉèÖÃXML¸ñʽ
Õâλ˵µÄ²»´í£»
ÔÚieÀïÃ棬ËüÄÜ°Ñxml×Ô¶¯½âÎö³ÆÊ÷Ðνṹ£¬ËùÒÔ¿´ÆðÀ´Ã»ÎÊÌ⣬ÔÚ¼Çʱ¾ÀïÃ棬¾Í²»ÐÐÁË£¬ÄãÒªÉèÖû»ÐС¢Ëõ½øµÄ¸ñʽ
ÄãΪÁ˼òµ¥£¬¿ÉÒÔÖ±½Óд£º
Java code
XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat()); ......
Java codeFormat ft=Format.getRawFormat();
ft.setEncoding("utf-8");
ft.setIndent(" ");//ÉèÖÃËõ½ø
XMLOutputter outputter=new XMLOutputter(ft);//ÉèÖÃXML¸ñʽ
Õâλ˵µÄ²»´í£»
ÔÚieÀïÃ棬ËüÄÜ°Ñxml×Ô¶¯½âÎö³ÆÊ÷Ðνṹ£¬ËùÒÔ¿´ÆðÀ´Ã»ÎÊÌ⣬ÔÚ¼Çʱ¾ÀïÃ棬¾Í²»ÐÐÁË£¬ÄãÒªÉèÖû»ÐС¢Ëõ½øµÄ¸ñʽ
ÄãΪÁ˼òµ¥£¬¿ÉÒÔÖ±½Óд£º
Java code
XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat()); ......
ÔÚ½øÐÐMISϵͳ¿ª·¢¹ý³ÌÖÐ,´ÓÅäÖÃÎļþÖжÁÈ¡ÅäÖÃÐÅÏ¢ÊÇÿһ¸öϵͳ±ØÐë¾ß±¸µÄ¹¦ÄÜ,ÀýÈç,ÎÒÃÇÒªÅäÖöÁÈ¡Êý¾Ý¿âÅäÖÃÐÅÏ¢,°üÀ¨Çý¶¯³ÌÐòÃû¡¢Á¬½Ó×Ö·û´®£¬Óû§Ãû£¬¿ÚÁîµÈÐÅÏ¢£¬ÓÉÓÚÕâЩÐÅÏ¢»áËæ×ÅÓû§µÄ²»Í¬¶ø·¢Éú¸Ä±ä£¬ËùÒÔ²»ÄÜÖ±½Ó°Ñ²ÎÊýдÔÚ³ÌÐòÖУ¬½«ÆäдÈëÅäÖÃÎļþ£¬È»ºóÔÚÓ¦ÓóÌÐòÖжÁÈ¡ÅäÖÃÐÅÏ¢²¢¼ÓÒÔʹÓã¬ÊÇÒ»¸ö³ÉÊìµÄMISϵͳ±ØÐë¾ßÓеĻù±¾¹¦ÄÜ¡£
JAVAÓëXMLÎļþ£¬¿ÉÒÔ˵ÊÇÈí¼þ¿ª·¢µÄ“»Æ½ð´îµµ”£¬¶øÈçºÎʹÓÃJAVAÍê³É¶ÔXMLÎļþµÄ¶ÁÈ¡£¬ÊÇÎÒÃÇÊ×ÏÈÒª½â¾öµÄÎÊÌâ¡£
Ò»¡¢XMLÎļþ
Õâ¸öʾÀýÎļþ°üÀ¨ÁËÓÃÀ´´ò¿ªORACLEÊý¾Ý¿âµÄ¸÷ÖÖ²ÎÊý
<?xml version="1.0" encoding="UTF-8"?>
<dbmsg>
<dbinfo>
<drivername>oracle.jdbc.driver.OracleDriver</drivername>
<sConnStr>jdbc:oracle:thin:@11.88.225.80:1521:VOUCHERDB</sConnStr>
<username>SYS AS SYSDBA</username>
<password>voucherdb</password>
</dbinfo>
</dbmsg>
¶þ¡¢±àдÀàÃûΪReadXmlµÄÀ࣬ÓÃÓÚ½âÎ ......
ÔÚ½øÐÐMISϵͳ¿ª·¢¹ý³ÌÖÐ,´ÓÅäÖÃÎļþÖжÁÈ¡ÅäÖÃÐÅÏ¢ÊÇÿһ¸öϵͳ±ØÐë¾ß±¸µÄ¹¦ÄÜ,ÀýÈç,ÎÒÃÇÒªÅäÖöÁÈ¡Êý¾Ý¿âÅäÖÃÐÅÏ¢,°üÀ¨Çý¶¯³ÌÐòÃû¡¢Á¬½Ó×Ö·û´®£¬Óû§Ãû£¬¿ÚÁîµÈÐÅÏ¢£¬ÓÉÓÚÕâЩÐÅÏ¢»áËæ×ÅÓû§µÄ²»Í¬¶ø·¢Éú¸Ä±ä£¬ËùÒÔ²»ÄÜÖ±½Ó°Ñ²ÎÊýдÔÚ³ÌÐòÖУ¬½«ÆäдÈëÅäÖÃÎļþ£¬È»ºóÔÚÓ¦ÓóÌÐòÖжÁÈ¡ÅäÖÃÐÅÏ¢²¢¼ÓÒÔʹÓã¬ÊÇÒ»¸ö³ÉÊìµÄMISϵͳ±ØÐë¾ßÓеĻù±¾¹¦ÄÜ¡£
JAVAÓëXMLÎļþ£¬¿ÉÒÔ˵ÊÇÈí¼þ¿ª·¢µÄ“»Æ½ð´îµµ”£¬¶øÈçºÎʹÓÃJAVAÍê³É¶ÔXMLÎļþµÄ¶ÁÈ¡£¬ÊÇÎÒÃÇÊ×ÏÈÒª½â¾öµÄÎÊÌâ¡£
Ò»¡¢XMLÎļþ
Õâ¸öʾÀýÎļþ°üÀ¨ÁËÓÃÀ´´ò¿ªORACLEÊý¾Ý¿âµÄ¸÷ÖÖ²ÎÊý
<?xml version="1.0" encoding="UTF-8"?>
<dbmsg>
<dbinfo>
<drivername>oracle.jdbc.driver.OracleDriver</drivername>
<sConnStr>jdbc:oracle:thin:@11.88.225.80:1521:VOUCHERDB</sConnStr>
<username>SYS AS SYSDBA</username>
<password>voucherdb</password>
</dbinfo>
</dbmsg>
¶þ¡¢±àдÀàÃûΪReadXmlµÄÀ࣬ÓÃÓÚ½âÎ ......
#include <iostream>
#include "1.h"
int main(int argc, char *argv[])
{
try
{
SXmlDOM dom;
//dom.parse("<?xml?><Êéµê><Êé±¾ ÊéÃû="VC++" ¼Û¸ñ="50" ÕÛ¿Û="1"/><Êé±¾ ÊéÃû="VB" ¼Û¸ñ="50" ÕÛ¿Û="0.8"/><Êé±¾ ÊéÃû="C#" ¼Û¸ñ="50" ÕÛ¿Û="0.7">ÓÐÔ´³ÌÐò¹âÅÌ</Êé±¾><¹ÒÀú><Äê·Ý>2006</Äê·Ý><¼Û¸ñ>50</¼Û¸ñ></¹ÒÀú></Êéµê>")
dom.parseFile("test.xml");
//²éѯ
SXmlElement& root = dom.root();
cout << "ÓÐ" << root.count("Êé±¾") << "±¾Êé!"<< endl;
cout << "VBµÄ¼Û¸ñ:" << (int)root.item("Êé±¾", 1)["¼Û¸ñ"] * (float)root.item("Êé±¾", 1)["ÕÛ¿Û"] << ......
Android ÊÇÕë¶ÔÒƶ¯É豸µÄÒ»ÖÖÐÂÐ˵ĿªÔ´²Ù×÷ϵͳºÍ SDK¡£½èÖúËü£¬Äú¿ÉÒÔ´´½¨¹¦ÄÜÇ¿´óµÄÒƶ¯Ó¦ÓóÌÐò¡£µ±ÄúµÄÓ¦ÓóÌÐò¿ÉÒÔ·ÃÎÊ Web ·þÎñʱ£¬ÆäÎüÒýÁ¦»á´ó´óÔö¼Ó£¬ÕâÒâζ×ÅÄúÐèҪʹÓà Web ÓïÑÔ£ºXML¡£ÔÚ±¾ÎÄÖУ¬Äú½«Á˽âÔÚ Android ÉÏʹÓà XML µÄ²»Í¬·½·¨£¬ÒÔ¼°ÈçºÎʹÓÃËüÃǹ¹½¨×Ô¼ºµÄ Android Ó¦ÓóÌÐò¡£
ÈëÃÅ
ÔÚ±¾ÎÄÖУ¬Äú½«Ñ§Ï°ÈçºÎ¹¹½¨Í¨¹ý Internet ʹÓà XML µÄ Android Ó¦ÓóÌÐò¡£Android Ó¦ÓóÌÐòÊÇʹÓà Java? ±à³ÌÓïÑÔ±àдµÄ£¬Òò´Ë¾ß±¸ Java ¼¼Êõ·½ÃæµÄ¾ÑéÊDZØÐèµÄ¡£Òª½øÐÐ Android ¿ª·¢£¬ÄúÐèҪʹÓà Android SDK¡£±¾ÎÄÖеÄËùÓдúÂëÊÊÓÃÓÚÈκΰ汾µÄ Android SDK£¬µ« SDK 1.5_pre ÊÇÓÃÓÚ¿ª·¢´úÂëµÄ¡£Äú¿ÉÒÔʹÓà SDK ºÍÒ»¸öÎı¾±à¼Æ÷À´¿ª·¢ Android Ó¦ÓóÌÐò£¬µ«Ê¹Óà Android Developer Tools (ADT)£¨Ò»¿î Eclipse ²å¼þ£©»á¸ü¼Ó¼òµ¥¡£ÔÚ±¾ÎÄÖУ¬ÎÒÃÇʹÓà 0.9 °æ±¾µÄ ADT ºÍ Eclipse 3.4.2, Java °æ±¾¡£ÓйØËùÓÐÕâЩ¹¤¾ßµÄÁ´½Ó£¬Çë²Î¼û ²Î¿¼×ÊÁÏ¡£
»ØÒ³Ê×
Android É쵀 XML
Android ƽ̨ÊÇÒ»¸ö¿ªÔ´Òƶ¯¿ª·¢Æ½Ì¨¡£ËüÔÊÐíÄú·ÃÎʸ÷ÖÖÒƶ¯É豸µÄËùÓз½Ã棬ÕâЩÒƶ¯É豸´ÓµÍ¼¶Í¼ÐÎÉ豸µ½ÊÖ»úÉãÏñÍ·ÉϵÄÓ²¼þ²»Ò»¶ø×ã¡£ÓÉÓÚ Android ¿ÉÒÔʵÏÖÕâô·á¸»µÄ¹¦ÄÜ£¬Òò´ËÄú¿ÉÄ ......
IsolatedStorageFile£º°üº¬ÎļþºÍÊý¾ÝµÄ¶ÀÁ¢´æ´¢Çø
datasetÊý¾Ý´æ´¢µ½±¾µØxmlÎĵµ£¬´úÂë´¦ÀíÈçÏÂ
public static void WriteDataToXML(DataSet dataset, string dataname)
{
try
{
IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForAssembly(); // »ñÈ¡Óëµ÷ÓôúÂëµÄ³ÌÐò¼¯±êʶ¶ÔÓ¦µÄÓû§·¶Î§µÄ¶ÀÁ¢´æ´¢
string fileName = "";
fileName = dataname.ToUpper() + ".xml";
using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream(fileName, FileMode.Create, isoStore))
{
using (StreamWriter writer = new StreamWriter(isoStream))
{
dataset.WriteXml(writer, XmlWriteMode.WriteSchema);
}
}
}
catch
{ }
}
Ïà¶ÔÓ¦µÄ´¦Àí·½Ê½Îª£º°´ÕÕ¸ø¶¨µÄÎļþÃû³Æ£¨xml£©¶ÁÈ¡Êý¾Ýµ½µ±Ç°µÄdatasetÖÐÒÔ±¸ºóÐøµÄÊý¾Ý²Ù×÷´¦Àí
´úÂëÈçÏ£º
public ......
×ܼǼÊý:815; ×ÜÒ³Êý:136; ÿҳ6 Ìõ;
Ê×Ò³ ÉÏÒ»Ò³ [1] [2] [3] [4] 5
[6] [7] [8] [9] [10] ÏÂÒ»Ò³ βҳ