Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

java ¶ÔxmlµÄÔöɾ¸Ä²é

<?xml version="1.0" encoding="UTF-8"?>
<root>
 <person id="1">
  <username >xiaoma</username>
  <password>xiaoma</password>
 </person>
 <person id="2">
  <username>manager</username>
  <password>password2</password>
 </person>
 <person id="3">
  <username>hello</username>
  <password>woerld</password>
 </person>
</root>
*****************************
package com.test;
import java.io.*;
import java.util.*;
import org.jdom.*;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
/**
 * xmlµÄÔöɾ¸Ä²éÖ®SAXBuilder
 *
 * @author Administrator
 *
 */
public class XmlTest {
 // ²éѯËùÓеÄÊý¾Ý
 public static void list() throws JDOMException, IOException {
  SAXBuilder builder = new SAXBuilder();
  String xmlPath = "message.xml";
  // String xmlPath = "./WebRoot/xml/message.xml";
  // »ñµÃÎĵµ¶ÔÏó
  Document document = builder.build(xmlPath);
  // »ñµÃ¸ù½Úµã
  Element root = document.getRootElement();
  List list = root.getChildren();
  System.out.println("root : " + root);
  System.out.println("root.getName : " + root.getName());
  System.out.println("listSize : " + list.size());
  Iterator it = list.iterator();
  while (it.hasNext()) {
   Element e = (Element) it.next();
   System.out.println("ID: " + e.getAttributeValue("id"));
   System.out.println("childUsername:" + e.getChildText("username"));
   System.out.println("childPassword:" + e.getChildText("password"));
  }
  // for(int i=0;i<list.size();i++){
  // Element e = (Element)list.get(i


Ïà¹ØÎĵµ£º

JAVAÊý¾Ý¿âÁ¬½Ó

 String uid=jTextField.getText();
 String upass=jTextField.getText();
 try {
      Class.forName("oracle.jdbc.driver.OracleDriver");//Òªµ¼ÈëÍⲿ°ü
      Connection conn=DriverManager.getConnection("jdbc:oracle:thin:scott ......

ÒøÐбÊÊÔÌâ java±ÊÊÔÌâ

1¡¢×÷ÓÃÓòpublic,private,protected,ÒÔ¼°²»Ð´Ê±µÄÇø±ð
  ´ð£º
Çø±ðÈçÏ£º  
×÷ÓÃÓò           µ±Ç°Àà       ͬһpackage     ×ÓËïÀà      ÆäËûpackage  
p ......

125Ìõ³£¼ûµÄjavaÃæÊÔ±ÊÊÔÌâ´ó»ã×Ü

1.³éÏ󣺡¡³éÏó¾ÍÊǺöÂÔÒ»¸öÖ÷ÌâÖÐÓ뵱ǰĿ±êÎ޹صÄÄÇЩ·½Ã棬ÒÔ±ã¸ü³ä·ÖµØ×¢ÒâÓ뵱ǰĿ±êÓйصķ½Ãæ¡£³éÏó²¢²»´òËãÁ˽âÈ«²¿ÎÊÌ⣬¶øÖ»ÊÇÑ¡ÔñÆäÖеÄÒ»²¿·Ö£¬ÔÝʱ²»Óò¿·Öϸ½Ú¡£³éÏó°üÀ¨Á½¸ö·½Ã棬һÊǹý³Ì³éÏ󣬶þÊÇÊý¾Ý³éÏó¡£  
2.¼Ì³Ð£º
¡¡¼Ì³ÐÊÇÒ»ÖÖÁª½áÀàµÄ²ã´ÎÄ£ÐÍ£¬²¢ÇÒÔÊÐíºÍ¹ÄÀøÀàµÄÖØÓã¬ËüÌṩÁËÒ»Ö ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ