javaÔõôÔÚXMLÖ¸¶¨Î»ÖòåÈë½Úµã - Java / Java SE
xmlÎļþ£º
<?xml version="1.0" encoding="utf-8"?>
<root>
<child ID="1"> old </child>
<child ID="2"> old </child>
</root>
--------------------------------------------
ÎÒÒªÔÚchildµÄID="1"ºÍID="2"Ö®¼ä²åÈë½ÚµãÔõô²åÈ룿²åÈëºóµÄЧ¹ûÈçÏ£º
<?xml version="1.0" encoding="utf-8"?>
<root>
<child ID="1"> old </child>
<child ID="3"> new </child> -->ÕâÊÇвåÈëµÄµÄ½Úµã
<child ID="2"> old </child>
</root>
----------------------------------------------------
ÎÒÓõÄÊÇDOM4JµÄjar°ü ,Çë¸ßÊÖÖ¸½Ì.
ºôºô£¬ÓÐûÓз¢´íλÖã¬ÕâÀïÓÐÈËÄܽâ¾ö°É£¿
APIÄã¿´¹ýÁËÂð£¿
SAXReader reader = new SAXReader();
Document doc = reader.read("conf/student.xml");
Element root = doc.getRootElement();
Element zhangsanNode = (Element) root.selectSingleNode(path);
Element cloneE = (Element) zhangsanNode.clone();
cloneE.element("age").setText(Integer.parseInt(cloneE.elementText("age"))+1+"");
Element parent = zhangsanNode.getParent();
parent.elements().add(2, cloneE);
Ïà¹ØÎÊ´ð£º
ÎÒJSPµÄÒ³ÃæÊÇ£º
<%@ page language="java" contentType="text/html; charset=gb2312"
%>
<script>
function Save(){
xmlHttp=GetXmlHttpObject()
if(xmlHttp==nul ......
¸÷·´óÏÀ¸ø¸ö˼·£¬²»ÊÇÔÚÏßµÄÄÇÖÖ£¬¾ÍÊÇÒ»¸ö×öÆÕͨµÄÓ¦ÓóÌÐò¡£
´Ê¿âÔõôÉú³ÉÄØ£¿
²»»á¡£
ÒýÓÃ
´Ê¿âÔõôÉú³ÉÄØ£¿
ÕÒ±¾×Öµä
ÒýÓÃ
´Ê¿âÔõôÉú³ÉÄØ£¿
Êý¾Ý¿â ºÇºÇ
ÓÃmap ¼üÖµ¶ÔÓ¦
Èç¹ûÓÃÊý¾Ý¿ ......
Private Sub Command1_Click()
Dim MyString() As String
Open "a.xml" For Binary As #1 ' ´ò¿ª¸Õ´´½¨µÄÎļþ¡£
ReDim MyString(LOF(1) - 1)
Put #1, , MyRecord ' ¶ÁÈëËùÓÐ×Ö·ûµ½±äÁ¿ÖÐ ......
ÒªÇó£º
1¡¢¾ßÓÐ2ÄêÒÔÉϵÄjava¿ª·¢¹¤×÷¾Ñ飬¾«Í¨java£»
2¡¢ÊìϤEclipse¿ª·¢¹¤¾ß£¬ÊìϤWEB¿ª·¢£¬¾ßÓÐÁ½ÄêÒÔÉÏJava¿ª·¢¾Ñ飬կÎÕÃæÏò¶ÔÏóµÄÈí¼þÉè¼Æ·½·¨£¬
ÓÐSpring¡¢HibernateÒÔ¼° ......
ÓÐËÓÃjava×ö¹ý´òÓ¡·¢Æ±µÄ³ÌÐò£¬¸Ð¾õÕâ·½Ãæ²»ÊǺܺÿØÖÆ£¬Ï£Íû¸øµã½¨Ò飬×îºÃÄܸø³ö´úÂë
¼òµ¥µã¾Íµ÷ÓÃwindow.print()
ÄãÒ²¿ÉÒÔ°ÑÏÂÃæ´úÂë·Åµ½ÄãJSPÖÐ:
<html>
<head>
<title> ......