·â×°Êý¾Ý¿âÇý¶¯³ÌÐò£¬ÓýâÎöxmlÎļþµÄ·½Ê½»ñÈ¡Çý¶¯£¿
<?xml version="1.0" encoding="UTF-8"?>
<database>
<dbinfo id="100">
<dirver>com.mysql.jdbc.Driver </dirver>
<url>jdbc:mysql://localhost:3306/testdb </url>
<username>root </username>
<password>321 </password>
</dbinfo>
</database>
½âÎöxml£º
public class DBParse {
static DBConfig config = new DBConfig();
public static DBConfig parseXml(){
ConnectionDB con = new ConnectionDB();
SAXBuilder builder = new SAXBuilder();
File file = new File("c://MysqlDB.xml");
try {
Document doc = builder.build(file);
Element root = doc.getRootElement();
List list = root.getChildren();
for(Iterator iterator = list.iterator();iterator.hasNext();)
{
Element dbinfo = (Element) iterator.next();
config.setDriver(dbinfo.getChildText("driver"));
config.setUrl(dbinfo.getChildText("url"));
config.setUsername(dbinfo.getChildText("username"));
config.setPassword(dbinfo.getChildText("password"));
}
} catch (JDOMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOExceptio
Ïà¹ØÎÊ´ð£º
txt ºÍXML ¸ñʽÏàÓ¦
²»½èÖúDataSet
µ¼Èë¶ÁÈ¡TXTÎļþ
È»ºóÖ±½ÓдÈëXML(ͬһÎļþ,²»Í¬Êý¾Ý,µÝÔöÔÊý¾ÝûÓб»¸²¸ÇÇé¿öÏÂÔö¼ÓÊý¾Ý.)
½Ì¸öÒªµã»ò×îºÃÊÇÓиö´úÂëÌáʾµÄ
¹ý·ºÃºº °ï¸öæÈö^^
²»»á£¬°ïÂ¥Ö÷ ......
ÏÖÔÚÎÒÒªÏòÒ»¸ö http://¡£¡£¡£¡£¡£¡£¡£¡£ µÄµØÖ··¢³öÒ»¸öÇëÇó£¬Õâ¸öÇëÇó»á·µ»Ø¸øÎÒÒ»¸öXML¸ñʽµÄÎļþ£¬ÇëÎÊÎÒÓ¦¸ÃÔõô½ÓÊÜÕâ¸öÎļþ²¢½âÎöËü£¬ÎÒÐèÒª½«½âÎö³öÀ´µÄÊý¾Ý´æÈëÊý¾Ý¿âÖУ¡£¡£¡£¡ÇëÎÊÎÒÓ¦¸ÃÓúÎÖÓ¼¼ÊõʵÏÖ£¿ ......
ÇëÎÊ.netÈçºÎ¶ÁÈ¡xmlµÄÖµ дµ½Êý¾Ý¿â Ï£Íû¸ø³öÍêÕûµÄ´úÂë лл
<?xml version="1.0" encoding="utf-8" ?>
- <channel>
- <item>
......
ÎÒµÄXMLÅäÖÃÎļþÀïÃæÓÐÖÐÎÄ×Ö·û,Ò²ÓÐÀàËÆÓÚ=~@!ÕâÖÖ×Ö·û,encodeingÉèÖÃΪgb2312 ºÍ unicode,unicode UTF-8,½á¹û¶¼Ìáʾϵͳ´íÎó,,,Èç¹ûÉèÖÃΪgb2312µÄ»°,È¥µô=!@ÕâÖÖ×Ö·û,Ò»Çж¼Õý³£.
ÓÉÓÚÎ ......
ÏÖÔÚ³ÌÐòÖÐÊÇͨ¹ýxmlHttp.responseXML»ñÈ¡ÁËÒ»¸öxml£¬¸ñʽÈçÏÂ
XML code:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<device>358279018906196</device ......