JAVA²Ù×÷XMLµÄÍêÕûÀý×Ó
JAVA²Ù×÷XMLµÄÍêÕûÀý×Ó——W3C DOM
JAVA²Ù×÷XMLµÄÍêÕûÀý×Ó——W3C DOMƪÊÕ²Ø
ÕâÊÇÒ»¸öÓÃJAVA W3C DOM ½øÐÐXML²Ù×÷µÄÀý×Ó£¬°üº¬Á˲éѯ¡¢Ôö¼Ó¡¢Ð޸ġ¢É¾³ý¡¢±£´æµÄ»ù±¾²Ù×÷¡£½ÏÍêÕûµÄÃèÊöÁËÒ»¸öXMLµÄÕû¸ö²Ù×÷Á÷³Ì¡£ÊʺϸÕÈëÃÅJAVA XML²Ù×÷µÄÅóÓѲο¼ºÍѧϰ¡£
¼ÙÉèÓÐXMLÎļþ£ºtest1.xml
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book>
<name>¹þÀﲨÌØ</name>
<price>10</price>
<memo>ÕâÊÇÒ»±¾ºÜºÃ¿´µÄÊé¡£</memo>
</book>
<book id="B02">
<name>Èý¹úÑÝÒå</name>
<price>10</price>
<memo>ËÄ´óÃûÖøÖ®Ò»¡£</memo>
</book>
<book id="B03">
<name>Ë®ä°</name>
<price>6</price>
<memo>ËÄ´óÃûÖøÖ®Ò»¡£</memo>
</book>
<book id="B04">
<name>ºìÂ¥</name>
<price>5</price>
<memo>ËÄ´óÃûÖøÖ®Ò»¡£</memo>
</book>
</books>
ÏÂÃæÊÇΪTest.java
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.*;
import javax.xml.xpath.*;
public class Test ...{
public static void main(String[] args) ...{
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
Element theBook=null, theElem=null, root=null;
try ...{
factory.setIgnoringElementContentWhitespace(true);
&n
Ïà¹ØÎĵµ£º
Ç°ÑÔ
XMLÔ½À´Ô½ÈÈ£¬¹ØÓÚXMLµÄ»ù´¡½Ì³ÌÍøÂçÉ ......
Ô¤±¸ÖªÊ¶—³ÌÐòµÄÄÚ´æ·ÖÅä
Ò»¸öÓÉC/C++±àÒëµÄ³ÌÐòÕ¼ÓõÄÄÚ´æ·ÖΪÒÔϼ¸¸ö²¿·Ö
1¡¢Õ»Çø£¨stack£©— ÓɱàÒëÆ÷×Ô¶¯·ÖÅäÊÍ·Å £¬´æ·Åº¯ÊýµÄ²ÎÊýÖµ£¬¾Ö²¿±äÁ¿µÄÖµµÈ¡£Æä²Ù×÷·½Ê½ÀàËÆÓÚÊý¾Ý½á¹¹ÖеÄÕ»¡£
2¡¢¶ÑÇø£¨heap£© — Ò»°ãÓɳÌÐòÔ±·ÖÅäÊÍ·Å£¬ Èô³ÌÐòÔ±²»ÊÍ·Å£¬³ÌÐò½áÊøʱ¿ÉÄÜÓÉOS»ØÊÕ ......
¹À¼ÆѧϰjavaµÄÂòÁËBruce Eckle¡¶Thinking In Java 4th Edition¡·µÄÐÂÊÖÃÇ£¨ÎÒÒ²ÊÇ£©£¬¹À¼Æ¶à»áÓöµ½Ò»¸öÎÊÌ⣺
±àÒëʱimport static net.mindview.util.Print.*;ÕÒ²»µ½ÏàÓ¦µÄ°ü£¬print·½·¨¾ÍÓò»ÁË¡£ÏÂÃæ°ÑÎҵIJÙ×÷·½·¨Ìù³öÀ´£¬Ï£ÍûÄÜ°ïµ½Äã¡£
1¡¢°ÑÊé±¾µÄÔ´´úÂë ......
Ê×ÏÈboolean²»ÄܸúÆäËûÀàÐÍת»»¡£
1.¸³ÖµÊ±£º
ÕûÊýĬÈϵÄÊÇint ¸¡µãĬÈÏÊÇdouble£¬¼´ÕûÐ͵ȺÅÓÒ²àÈ«²¿×Ô¶¯×ª»¯Îªint£¬¸¡µãÐ͵ȺÅÓÒ²à×Ô¶¯×ª»»Îªdouble¡£µ±´óÈÝÁ¿µÄÊý¾ÝÀàÐ͸³Öµ¸øСÈÝÁ¿µÄÊý¾ÝÀàÐÍʱ ÐèҪǿÖÆÀàÐÍת»»µ«ÊÇÓÐ ......