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

³õѧXML£¨¶þ£© XML½âÎöÆ÷

XML½âÎöÆ÷µÄ×÷ÓãºÎªÓ¦ÓóÌÐò´ÓXMLÎļþÖнâÎö³öËùÐèÒªµÄÊý¾Ý¡£
ÏÂÃæͨ¹ýÒ»¸öÀý×Ó£¬À´Á˽⣬ÈçºÎÓÃXML½âÎöÆ÷£¬À´½âÎöÒ»¸öXMLÎļþÖеÄÊý¾Ý¡£
1¡¢Types.xml£¨ÏÔʾ¼ªËûµÄÀà±ð£©
<?xml version="1.0" encoding="UTF-8"?>
<types>
<name>µç¼ªËû
<music>ÍæÒ¡¹ö</music>
</name>
<name>ľ¼ªËû
<music>ÍæÃñÒ¥</music>
</name>
</types>
2¡¢MyHandler.java (×Ô¼ºÐ´Ò»¸ö±¨´íµÄʼþ´¦ÀíÀ࣬ÓÃÀ´±¨¸æXML ½âÎö´íÎó¡£)
package XmlTest;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
/**
* @author ÍõÓÀÌÎ
*
*/
class MyHandler extends DefaultHandler
{
String errorMessage=null;
public void error(SAXParseException e) throws SAXException
{
errorMessage=e.getMessage();
System.out.println("Ò»°ã´íÎó£º"+errorMessage);
}
public void fatalError(SAXParseException e) throws SAXException
{
errorMessage=e.getMessage();
System.out.println("ÖÂÃü´íÎó£º"+errorMessage);
}
}

3 TestXml.java(½âÎöÆ÷£ºÓÃÀ´½âÎöÉÏÊöTypes.xmlÎļþÖÐname ºÍmusicËù±ê¼ÇµÄÄÚÈÝ)
package XmlTest;
import java.io.File;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
/**
* @author ÍõÓÀÌÎ 2009-12-22
*
*/
public class TestXml
{
/**
* @param args
*/
public static void main(String[] args)
{

try
{
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
DocumentBuilder builder=factory.newDocumentBuilder();
MyHandler handler=new MyHandler();
builder.setErrorHandler(handler);
//ÇмǣºÕâ¸öXMLÎļþ£¬ÒªÐ´¾ø¶Ô·¾¶²ÅÐÐ


Ïà¹ØÎĵµ£º

SAXReaderµÄÖ÷ÒªÓ÷¨£¨XML£©


java ´úÂë
package com.dc.framework.taglib;   
import java.io.FileInputStream;   
import java.io.FileNotFoundException;   
import java.util.HashMap;   
import java.util.Iterator;   
import java.util.List; &nb ......

Open XML£ºÒ»ÖÜÄê¼Ç

¿ÉÄÜÄúÒѾ­Ìý˵ÁË£¬±¾ÖÜÊÇ Microsoft ÊÂÒµ²¿ºÜ¹Ø¼üµÄÒ»ÖÜ¡£ÔÚ±¾ÖÜÔçЩʱºò£¬ÎÒÃÇÐû²¼½«¹«¿ª·¢ÐÐ Microsoft Office 2010 Beta¡£ÄúÊÇ·ñÔøÏ£ÍûÓëÍŶÓÒ»ÆðÔÚ Word Öй²Í¬´´×÷Ò»·ÝÎĵµ£¿ÄúÊÇ·ñÔøÏ£ÍûÔÚ Excel ÖÐͬʱ·ÖÎö³É¶ÑµÄÊý¾Ý£¿»òÕßÔÚ PowerPoint ÑÝʾÎĸåÖÐÍ»ÆƶàýÌåµÄÏÞÖÆ£¿ÄÇô£¬¸Ï¿ìÊÔÊÔ Beta °æ±¾°É¡£
¶ÔÓÚ±ê×¼ÉçÇø£ ......

(4).¶ÁÈ¡XMLÎļþ

//¶ÁÈ¡XMLÎļþ
//1¡¢LoadfromFile×°ÈëXMLÎļþ
//2¡¢Ö¸¶¨Â·¾¶£¬¼¤»î¶ÁÈ¡
//3¡¢´ÓÄÚ´æÁ÷¶ÁÈ¡
//4¡¢´ÓÍøÂçÉÏÖ±½Ó»ñÈ¡
//1¡¢LoadfromFile×°ÈëXMLÎļþ
procedure TForm1.Button1Click(Sender: TObject);
begin
XMLDocument1.LoadfromFile('c:\temp\test.xml');
// XMLDocument1.Active := True;
Memo1.Lines := X ......

xmlת»»Îªdataset

        /// <summary>
        /// ¶ÁÈ¡Êý¾Ý¼¯²¢¼ÓÈ뻺´æ
        /// sea 2009-12-11
        /// </summary>
      &nb ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ