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

ʹÓÃSAX½âÎöXML

SAX£¨Simple API for XML¼ò³ÆSAX£©Ê¼þÊÇÎÞ״̬µÄ£¬Ò²¾ÍÊÇ˵£¬µ±½ÓÊÕµ½×Ö·ûÊý¾ÝµÄʼþºó£¬²¢²»ÖªµÀ¸Ã×Ö·ûÊý¾ÝÊÇÄÄÒ»¸öÔªËØµÄ
ÄÚÈÝ¡£Í¬ÑùµØ£¬µ±ÊÕµ½ÔªËØ¿ªÊ¼µÄʼþºó£¬Ò²ÎÞ·¨ÖªµÀ¸ÃÔªËØÊÇ·ñÓи¸ÔªËØ£¬ÊÇ·ñÓÐ×ÓÔªËØ£¬ÕâÊÇ
SAXºÍDOM²»Í¬µÄµØ·½¡£SAX½âÎöÆ÷±¾Éí²¢²»Ìá¹©ÔªËØµÄÉÏÏÂÎÄÐÅÏ¢£¬ËùÓÐÏà¹ØÐÅÏ¢µÄ¼Ç¼ÐèÒªÎÒÃÇ×Ô
¼º±à³ÌȥʵÏÖ
SaxXmlÀà¼ÓÔØXMLÊý¾ÝÁ÷£¬£¨Ä¿Ç°ÓÃ×Ö·û´®´úÌæ£©£¬½¨Á¢½âÎö¹¤³§£¬Éú²úSAX½âÎö¶ÔÏó
import java.io.ByteArrayInputStream;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.SAXException;
public class SaxXml {
private SaxXml() {
       }
SaxXml(String xmlFile) {
        try{
    String xmltest = "<?xml version=\"1.0\" encoding=\"gb2312\"?>"
      +"<home>"
      +"<name>ÕÅÈý</name>"
      +"<sex>ÄÐ</sex>"
      +"<age>20</age>"
      +"</home>";   
      byte[] data1 = xml.getBytes();
  
      SAXParserFactory factory = SAXParserFactory.newInstance();
      factory.setValidating(true);
    SAXParser sax = factory.newSAXParser();
    sax.parse(new ByteArrayInputStream(data1), XmlHandler.handler/*new XmlHandler()*/ );
   } catch (ParserConfigurationException pce) {
    System.out.println("Could not create that parser.");
    System.out.println(pce.getMessage());
   } catch (SAXException saxe) {
    System.out.println("Problem wITh the SAX parser.");
    System.out.println(saxe.getMessage());
   } catch (Exception e) {
    e.printStackTrace();
  &n


Ïà¹ØÎĵµ£º

IsolatedStorageFile ±¾µØÊý¾Ý»º´æ xml dataset ¶Áд

IsolatedStorageFile£º°üº¬ÎļþºÍÊý¾ÝµÄ¶ÀÁ¢´æ´¢Çø
datasetÊý¾Ý´æ´¢µ½±¾µØxmlÎĵµ£¬´úÂë´¦ÀíÈçÏÂ
public static void WriteDataToXML(DataSet dataset, string dataname)
{
try
{
IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForAssembly(); / ......

Linq to XML customize distinct function

Definition comparer class,
class ItemComparer : IEqualityComparer<XElement>
{
public bool Equals(XElement x, XElement y)
{
return x.Attribute("Name").Value == x.Attribute("Name").Value;
}
public int GetHashCode(XElement obj)
......

xmlÎļþ²Ù×÷С½á ¹ØÓÚ·½·¨SelectSingleNodeµÄÓ÷¨

×î³£¼ûµÄXMLÊý¾ÝÀàÐÍÓУºElement, Attribute£¬Comment, Text.
  Element, Ö¸ÐÎÈç<Name>Tom<Name>µÄ½Úµã¡£Ëü¿ÉÒÔ°üÀ¨£ºElement, Text, Comment, ProcessingInstruction, CDATA, and EntityReference.
  Attribute, Ö¸ÔÚ<Employee id=”12345”>ÖеĴÖÌ岿·Ö¡£
 &nb ......

XmlÖÐSelectSingleNode·½·¨ÖеÄxpathÓ÷¨

×î³£¼ûµÄXMLÊý¾ÝÀàÐÍÓУºElement, Attribute£¬Comment, Text.  
 
   Element, Ö¸ÐÎÈç<Name>Tom<Name>µÄ½Úµã¡£Ëü¿ÉÒÔ°üÀ¨£ºElement, Text, Comment, ProcessingInstruction, CDATA, and EntityReference.  
 
   Attribute, Ö¸ÔÚ<Employee >ÖеĴ ......

XMLÌØÊâ·û號

ÔÚweb.config×ö參數設¶¨時Óöµ½ÌØÊâ×ÖÔª value="http://www.yahoo.com.tw/default.aspx?sid=111111111&uid=test"
&uid這µØ·½會³ö錯...換³É&amp;uid ¾ÍOKÁË~~
幾個
對ÕÕÈçÏÂ:
< Сì¶
&lt;
> ´óì¶
&gt;
&
&amp ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ