¼±£¡¼±!!ÈçºÎÑéÖ¤xmlÎļþµÄÓÐЧÐÔ£¿
ÈçºÎÑéÖ¤xmlÎļþµÄÓÐЧÐÔ?
ÇëÇó°ïÖú£¬Ð»Ð»
Java code:
////XSDTest.java:
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXParseException;
import org.w3c.dom.Document;
public class XSDTest implements ErrorHandler
{
public static void main(String[] args)
{
DocumentBuilderFactory docBuilderFactory = null;
DocumentBuilder docBuilder = null;
try
{
docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setValidating(true);
docBuilderFactory.setNamespaceAware(true);
docBuilder = docBuilderFactory.newDocumentBuilder();
docBuilder.setErrorHandler(new XSDTest());
Document doc = docBuilder.parse("WellFormed.xml");
}
catch(Exception se)
{
se.printStackTrace();
}
}
public void error(SAXParseException se)
{
System.out.println("Caught an error:" + se.getMessage());
//se.printStackTrace();
}
public void fatalError(SAXParseException se)
{
System.out.println("Caught an fatal error.");
se.printStackTrace();
}
Ïà¹ØÎÊ´ð£º
ÈçºÎ¶ÔxmlÄÚÈÝÊý¾Ý½øÐбȽÏ
ÀýÈ磺
<?xml version='1.0' encoding='utf-8'?>
<TestLIST>
<PID>40</PID>
<TestName>ÉîÛÚÊÐ</TestName>
......
ÎÒÔÚ±àдһ¸öwince5.0µÄ³ÌÐò£¬ÏëʵÏÖ°ÑPDAÉϵÄÒ»¸öLIST <STRING>ÀàÐ͵ÄÊý¾ÝÐòÁл¯ÎªXML£¬È»ºóÔÚPCÉϵÄÒ»¸öwebserviceÄõ½Õâ¸öXML£¬×ª»¯ÎªDataset£¬¸üÐÂPCÉϵÄÊý¾Ý¿â£¬ÎÒÏëÎÊÔõô°ÑXML´«¸øwebserviceµÄÄØ£¿
......
ÄÚÈÝÈçÌâ¡£¡£ÔÚC#Àï¸ÄÈçºÎÐ´ÄØ£¿
±¾À´Ë¼Â·ÊÇÏȱȶԽڵãÃû³Æ£¬ÈçÊǵϰ¾Í±£´æÒªÉ¾³ý½ÚµãµÄϱê·ÅÔÚÊý×éÀȻºóÑ»·É¾³ý£¬µ«·¢ÏÖ¡£¡£µ±ÎÒɾ³ýµÚÒ»¸öºó£¬ËùÓнڵãϱêÊýÁ¿¶¼·¢Éú¸Ä±ä¡£¡£
¾Í²»ÄÜÔÙ°´ÕÕ֮ǰ¼Í¼µÄ½Úµã ......
ΪʲôÎҵijÌÐòµ÷ÓÃXMLÅäÖÃÎļþÖеİ¢À²®ÎÄÏÔʾ²»³öÀ´£¿ÆäËûµÄÓïÖÖ¶¼¿ÉÒÔ£¬ÈçÖÐÎÄ£¬Ó¢ÎÄ£¬µÂÎͼ¿É¡£
ÎÒ½«XMLµÄ±àÂë¸ÄΪutf-8ºÍunicodeµÄµ½µÃ½á¹û¶¼Ò»Ñù.
°¢À²®ÎĵÄ×Ö¿âÄãÓÐô£¿
ÓÐ,ÎÒµÄEXEÊÇ·ÅÔÚpc»úÉÏÖ´Ðе ......