Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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Îļþ£¬ÒªÐ´¾ø¶Ô·¾¶²ÅÐÐ


Ïà¹ØÎĵµ£º

(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 ......

c# ´ÓXML¶ÁÊý¾Ý

C#
 DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("~/Config/User_yhlx_Jb.xml"));
DataView dv = ds.Tables[0].DefaultView;
//dv.RowFilter = "State=0";
this.DropDownList1.DataSource = dv;
this.DropDownList1.DataTextField = "text";
this ......

xml²Ù×÷

     protected void Button1_Click(object sender, EventArgs e)
        {
            //Ϊresponse(star)½Úµã ºÍ  Cabins(f) cabin½Úµã·Ö±ðÌí¼Ó¸ö
      &nbs ......

XML Schema ²Î¿¼ÊÖ²á1

XML Schema ²Î¿¼ÊÖ²á
XSD ÔªËØ
ÔªËØ
½âÊÍ
all
¹æ¶¨×ÓÔªËØÄܹ»ÒÔÈÎÒâ˳Ðò³öÏÖ£¬Ã¿¸ö×ÓÔªËؿɳöÏÖÁã´Î»òÒ»´Î¡£
annotation
annotation ÔªËØÊÇÒ»¸ö¶¥²ãÔªËØ£¬¹æ¶¨ schema µÄ×¢ÊÍ¡£
any
ʹ´´×÷Õß¿ÉÒÔͨ¹ýδ±» schema ¹æ¶¨µÄÔªËØÀ´À©Õ¹ XML Îĵµ¡£
anyAttribute
Ê ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ