ËÄÖÖXML½âÎö·½·¨
ËÄÖÖXML½âÎö·½·¨
xmlÎļþ£º
£¼?xml version="1.0" encoding="GB2312"?£¾
£¼RESULT£¾
£¼VALUE£¾
£¼NO£¾A1234£¼/NO£¾
£¼ADDR£¾ËÄ´¨Ê¡XXÏØXXÕòXX·X¶ÎXXºÅ£¼/ADDR£¾
£¼/VALUE£¾
£¼VALUE£¾
£¼NO£¾B1234£¼/NO£¾
¡¡ ¡¡£¼ADDR£¾ËÄ´¨Ê¡XXÊÐXXÏçXX´åXX×飼/ADDR£¾
£¼/VALUE£¾
£¼/RESULT£¾
1£©DOM
import java.io.*;
import java.util.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
public class MyXMLReader{
¡¡public static void main(String arge[]){
long lasting =System.currentTimeMillis();
try{
¡¡File f=new File("data_10k.xml");
¡¡DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
¡¡DocumentBuilder builder=factory.newDocumentBuilder();
¡¡Document doc = builder.parse(f);
¡¡NodeList nl = doc.getElementsByTagName("VALUE");
¡¡for (int i=0;i£¼nl.getLength();i++){
System.out.print("³µÅƺÅÂë:" +
doc.getElementsByTagName("NO").item(i).getFirstChild().getNodeValue());
System.out.println("³µÖ÷µØÖ·:" +
doc.getElementsByTagName("ADDR").item(i).getFirstChild().getNodeValue());
¡¡ ¡¡}
}catch(Exception e){
¡¡e.printStackTrace();
}
import java.io
Ïà¹ØÎĵµ£º
using System.Xml;//Í·²¿¼Ó´ËÃüÃû¿Õ¼ä
XmlDocument xd = new XmlDocument();//±íʾXMLÎĵµ
XmlDeclaration xde;//±íʾ XML ÉùÃ÷½Úµã£º<?xml version='1.0'...?>
xde = xd.Cre ......
ÓÃTXT±à¼ÁËÒ»¸öXMLÎĵµ
<?xml version="1.0" encoding="utf-8"?>
<TEST>"
<Test Value="ÕâÊÇÒ»¸ö²âÊÔ" />
</TEST>
ÓÃIE´ò¿ªµÄʱºòÒ»Ö±ÏÔʾÓдíÎó£¬ÏÔʾººÓï×Ö·û²»Ö§³Ö¡£
¸ÄΪencoding=“gb2312”ºóÏÔʾÕý³£ÁË¡£
µ«Õâ¸ö½á¹ûÓë³õÖÔÎ¥±³£¬ÒòΪUTF-8ÊÇÖ§³ÖËùÓÐÓïÑԵġ£
ºóÀ´²éÕÒÔÒ ......
XML (EXtensible Markup Language)
XML is a
cross-platform, software and hardware independent tool for transmitting
information.
Prolog
XML
Declaration
Processing
Instructions
DOCTYPE
Declaration
Elements
Attributes
XML
Comments
CDATA
Sections
Character
and Entity Refere ......
Internet Explorer 5.0 ¶Ô XML ÌṩÄĸö¼¶±ðµÄÖ§³Ö£¿
¡¡¡¡Internet Explorer 5 ÌṩÏÂÁÐ XML Ö§³Ö£º
¡¡¡¡Ö±½Ó²é¿´ XML¡£Microsoft XML ʵÏÖÔÊÐíÓû§Í¨¹ýËûÃÇµÄ Web ä¯ÀÀÆ÷ʹÓà XSL »òÕß²ãµþÑùʽ±í (CSS) ²é¿´ XML£¬¾ÍÏó²é¿´ HTML ÎĵµÒ»Ñù¡£
¡¡¡¡¸ßÐÔÄÜ¡¢ÑéÖ¤ XML ÒýÇæ¡£Internet Explorer 4.0 ¿ª·¢ÈËÔ±ÊìϤµÄ XML ÒýÇ ......
ÒÑÖªÓÐÒ»¸öXMLÎļþ£¨bookstore.xml£©ÈçÏ£º
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
<title>Oberon's Legacy</title>
<author>Corets, Eva</author>
<price>5.95</price>
</book>
</booksto ......