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

java ²Ù×÷XMLÎļþ£¨Æ¬¶Î£©

//create a new Document
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document d = db.newDocument();

//add root Node
Element noteuser = d.createElement("note-users");
d.appendChild(noteuser);

//add exists Node
Document readXML = db.parse(new File("c:\\note-user.xml"));
NodeList nl = readXML.getElementsByTagName("user");
for(int i = 0; i < nl.getLength(); i++)
{
Element n = d.createElement("user");
n.setAttribute("name", nl.item(i).getAttributes().getNamedItem("name").getNodeValue());
if(id !=null && id.equals(nl.item(i).getAttributes().getNamedItem("name").getNodeValue()))
{
//duplicate id (redirect to error page)
response.getWriter().print("<font color = red>duplicate id !</font>");
response.getWriter().print("      ");
response.getWriter().print("<a href = \"reg.jsp\">return to login page</a>");
return;
}
n.setAttribute("password", nl.item(i).getAttributes().getNamedItem("password").getNodeValue());
noteuser.appendChild(n);
}

//add regist Node
Element n = d.createElement("user");
n.setAttribute("name", id);
n.setAttribute("password", pwd);
noteuser.appendChild(n);

//save data to file
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
DOMSource source = new DOMSource(d);

//file's path
StreamResult result = new StreamResult(new File("c:\\note-user.xml"));
transformer.transform(source, resu


Ïà¹ØÎĵµ£º

JAVA±Ê¼Ç£¨ËÄ£©

ÃæÏò¶ÔÏóµÄÈý´óÌØÕ÷£º·â×°¡¢¼Ì³Ð¡¢¶à̬¡£
javaÖеķâ×°
·â×°£¬Ò»¸ö¶ÔÏóºÍÍâ½çµÄÁªÏµÓ¦µ±Í¨¹ýÒ»¸öͳһµÄ½Ó¿Ú£¬Ó¦µ±¹«¿ªµÄ¹«¿ª£¬Ó¦µ±Òþ²ØµÄÒþ²Ø¡££¨¶ÔÏóµÄÊôÐÔÓ¦µ±Òþ²Ø£©£¬Ò»¸ö¶ÔÏóµÄÄÚ²¿ÊÇ͸Ã÷µÄ£¬¾ÍÊǰѶÔÏóÄÚ²¿µÄ¿É͸Ã÷ÐÔºÍÒþ²ØµÄÌØÐÔÇø·Ö¿ª£¬¸Ã͸Ã÷µÄ͸Ã÷£¬¸ÃÒþ²ØµÄÒþ²Ø¡£
£¨·â×°µÄÊôÐÔ£©javaÖÐÀàµÄÊôÐԵķÃÎÊȨÏÞµÄĬ ......

JAVA±Ê¼Ç£¨Î壩

javaÖеÄÐÞÊηû
static ±íʾ¾²Ì¬£¬Ëü¿ÉÒÔÐÞÊÎÊôÐÔ£¬·½·¨ºÍ´úÂë¿é¡£
1£¬staticÐÞÊÎÊôÐÔ£¨Àà±äÁ¿£©£¬ÄÇôÕâ¸öÊôÐԾͿÉÒÔÓà ÀàÃû.ÊôÐÔÃû À´·ÃÎÊ£¬Ò²¾ÍÊÇʹÕâ¸öÊôÐÔ³ÉΪ±¾ÀàµÄÀà±äÁ¿£¬Îª±¾Àà¶ÔÏóËù¹²ÓС£Õâ¸öÊôÐÔ¾ÍÊÇÈ«À๫ÓС££¨¹²ÓеÄÀà±äÁ¿Óë¶ÔÏóÎ޹أ¬Ö»ºÍÀàÓйأ©¡£
Àà¼ÓÔØµÄ¹ý³Ì£¬Àà±¾ÉíÒ²ÊDZ£´æÔÚÎļþÖУ¨×Ö½ÚÂëÎļþ± ......

JAVA·´ÉäС½á

1  JAVAµÄ·´Éä,Æäʵ¾ÍÊÇͨ¹ýÒ»¸öʵÀý»¯µÄ¶ÔÏó·´¹ýÀ´È¥ÕÒµ½Ò»¸öÀàµÄÍêÕûÐÅÏ¢,±ÈÈç¶ÔÓÚÈçϵÄÐÎʽ:
X x=new X();
   x.getClass().getName();
ÕâÀï¾Í»áÊä³öÕâ¸öÀàËùÔÚµÄÍêÕûÐÅÏ¢,¼´"°üÃû.ÀàÃû";
  ×î³£ÓõÄÈýÖÖʵÀý»¯CLASSÀà¶ÔÏó
Class<?> c1 = null ;  // Ö¸¶¨·ºÐÍ
  C ......

MsXml´´½¨ºÍ½âÎöXMLʾÀý

Ò»£®MsXml´´½¨XMLÎĵµÊ¾Àý
 // XmlCreationDemo.cpp
#include <stdlib.h>
#include <stdio.h>
// ÒýÈëMSXML½âÎöÆ÷
#import <msxml4.dll>
using namespace MSXML2;
class InitializeCom
{
public:
InitializeCom() { CoInitialize(NULL); // Initializes the COM library }
~Initializ ......

JavaÁ¬½ÓSQL Server 2000

Êý¾Ý¿â²Ù×÷ÏÖÔÚÊÇÏîÄ¿¿ª·¢µÄ¸ù±¾£¬Ñ§Ï°JavaÊ×ÏÈÓ¦¸Ãѧ»áÔõôÑùÁ¬½ÓÊý¾Ý¿â£¬ÓÃJavaÁ¬½ÓÊý¾Ý¿â¿É²»ÏñÓÃDelphiÕâÀ๤¾ßÄÇÑùÉ輸¸öÊôÐÔ¾ÍOK£¬Ëµ¼òµ¥Ò²¼òµ¥£¬Ëµ¸´ÔÓ£¬ÆäʵҲͦ¸´Ôӵ쬶øÇÒºÜÂé·³£¬Èç¹ûÊdzõѧ£¬¸ù±¾²»Äܱ£Ö¤µÚÒ»´Î¾ÍÁ¬½Ó³É¹¦£¬ÏÂÃæÒÔSQL Server 2000ΪÀý£¬ËµËµJavaÁ¬½ÓÊý¾Ý¿âµÄ»ù±¾·½·¨£¬Ò²¼Ç¼һÏÂÐĵá£
1¡¢Ï ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ