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

StAX Éú³ÉXMLÎļþ

²Î¿¼£º°Ù¶È°Ù¿Æ http://baike.baidu.com/view/1027076.htm?fr=ala0
ÔÚJDK 6.0ÖлùÓÚStAX·ÖÎöXMLÊý¾Ý£º http://hi.baidu.com/1shome/blog/item/5baaee01db2609051d958302.html
DOM¡¢SAX
¡¢DOM4J¡¢JDOM¡¢StAXÉú³ÉXML
²¢·µ»ØXML×Ö·û´®ÐÎʽ£ºhttp://dreams75.javaeye.com/blog/512319
STAX:Streaming API for XML (StAX)
Õë¶ÔÓÚXMLµÄÁ÷ʽAPI(StAX)£¬ÊÇÔÚ2004Äê3ÔµÄJSR 173¹æ·¶ÖÐÒýÈ룬ÕâÊÇÒ»ÖÖÕë¶ÔXMLµÄÁ÷ʽÀ­·ÖÎöAPI¡£StAXÊÇJDK
6.0ÌṩµÄÒ»ÖÖÐÂÌØÕ÷¡£StAXͨ¹ýÌṩһÖÖ»ùÓÚʼþµü´úÆ÷(Iterator)µÄAPIÈÃ
³ÌÐòԱȥ¿ØÖÆxmlÎĵµ½âÎö¹ý³Ì,³ÌÐò±éÀúÕâ¸öʼþµü´úÆ÷È¥´¦Àíÿһ¸ö½âÎöʼþ£¬½âÎöʼþ¿ÉÒÔ¿´×öÊdzÌÐòÀ­³öÀ´µÄ£¬Ò²¾ÍÊdzÌÐò´Ùʹ½âÎöÆ÷²úÉúÒ»¸ö½âÎöʼþ
È»ºó´¦Àí¸Ãʼþ£¬Ö®ºóÓÖ´Ùʹ½âÎöÆ÷²úÉúÏÂÒ»¸ö½âÎöʼþ£¬Èç´ËÑ­»·Ö±µ½Åöµ½Îĵµ½áÊø·û£»
SAX
Ò²ÊÇ»ùÓÚʼþ´¦ÀíxmlÎĵµ£¬µ«È´ÊÇÓÃÍÆÄ£Ê½½âÎö£¬½âÎöÆ÷½âÎöÍêÕû¸öxmlÎĵµºó£¬²Å²úÉú½âÎöʼþ£¬È»ºóÍÆ¸ø³ÌÐòÈ¥´¦ÀíÕâЩʼþ£»
Ò»¡¢ ÍÆ·ÖÎöÖ®ÓÚÀ­·ÖÎö
¡¡¡¡±È½ÏÓÚÍÆ·ÖÎö£¬À­·ÖÎö¾ßÓÐÈçÏÂһЩÓŵ㣺
¡¡¡¡1.
ÔÚÀ­·ÖÎöÖУ¬Ê¼þÊÇÓÉ·ÖÎöÓ¦ÓóÌÐòÉú³ÉµÄ£¬Òò´Ë°Ñ·ÖÎö¹æÔòÌṩµ½¿Í»§¶Ë¶ø²»ÊÇ·ÖÎöÆ÷¡£
¡¡¡¡2.
À­·ÖÎöµÄ´úÂë¸ü¼òµ¥²¢ÇÒËü±ÈÍÆ·ÖÎöÓиüÉٵĿ⡣
¡¡¡¡3. À­·ÖÎö¿Í»§¶ËÄÜͬʱ¶Á¶à¸öXMLÎĵµ¡£
¡¡¡¡4.
À­·ÖÎöÔÊÐíÄã¹ýÂËXMLÎĵµ²¢ÇÒÌø¹ý·ÖÎöʼþ¡£
¶þ¡¢
ʹÓÃXMLStreamWriter½øÐÐд²Ù×÷
¡¡¡¡Ê×ÏÈ£¬ÄãÒª´´½¨½«´ý·ÖÎöµÄXMLÎĵµ¡£ÓÉStAXµÄXMLStreamWriterÉú³ÉXML¡£È»¶ø£¬XMLStreamWriterµÄÒ»¸öÏÞÖÆÊÇ£¬Ëü²»Ò»¶¨»áÉú³ÉÁ¼¹¹µÄÎĵµ-¶øÇÒÉú³ÉµÄÎĵµÒ²²»Ò»¶¨ÊÇÓÐЧµÄ¡£ÄãÐèҪȷ±£Éú³ÉµÄXMLÎĵµÊÇÁ¼¹¹µÄ¡£Áбí1ÊÇÒ»¸öÓÉXMLStreamWriterÉú³ÉµÄԭʼXMLÎĵµµÄʾÀý¡£
1.µ¼ÈëSaTXÀà
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
2.ÄãÒª´ÓÒ»¸öXMLOutputFactoryÖеõ½ÄãµÄXMLStreamWriter¡£Òò´Ë£¬Ê×ÏÈÄã±ØÐë´´½¨Ò»¸öеÄXMLOutputFactory£º
//¶¨ÒåÓÃÓÚ»ñÈ¡ XMLEventWriter ºÍ XMLStreamWriter µÄ¹¤³§³éÏóʵÏÖ
XMLOutputFactory xof = XMLOutputFactory.newInstance();
3.½ÓÏÂÀ´£¬´´½¨Ò»¸öFileWriter»òÕßPrintWriterÒÔÊä³öXMLÎĵµ-Ëü½«±»Éú³Éµ½Ò»¸öXMLÎļþÖУº
PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream("Catalog-StAX.xml"),"utf-8&quo


Ïà¹ØÎĵµ£º

XML½âÎö¼¼Êõ

 XMLѧϰÍêÁË£¬ÀÏʦ˵ÔÚÃæÊÔµÄʱºòÓпÉÄÜÒªÎʵ½ÕâЩ£¬ËùÒÔÓÖÕÒÁËЩ×ÊÁÏ£¬ÔÚMLDNµÄÕâ¶ÎÈÕ×ÓÀÀÏʦÃǶ¼°Ñ¸÷¸öÃæÊÔÖÐÓпÉÄÜÒªÎʵ½µÄÎÊÌâ¶¼°ïÎÒÃÇÒ»Ò»×Ü½á£¬ÕæµÄºÜ¸ÐлMLDNµÄÈ«²¿ÀÏʦ,ÏîÄ¿ÀÏʦ°ïÎÒÃÇÈÏÕæµÄ½²½âÏîÄ¿£¬¸¨µ¼ÏîÄ¿£¬½ÌѧÀÏʦ°ïÎÒÃÇÈÏÕæ×ܽá¸÷¸ö¼¼Êõ£¬¸Ðл£¬ÕæµÄÊǸÐл£¬ºÇºÇ£¬ÎÒ»áŬÁ¦¸ãºÃµÄ
JavaÖÐËÄÖÖXML ......

javascript¿çä¯ÀÀÆ÷´´½¨XML¶ÔÏó


var
 
xmlDoc
 
=
 
null
;
function
 
parseXML
(
xmlUrl
)
{
¡¡¡¡try
 
{
¡¡¡¡¡¡¡¡//IE
¡¡¡¡¡¡¡¡xmlDoc
 
=
 
new
 
ActiveXObject
(
"Microsoft.XMLDOM"
);
¡¡¡¡¡¡¡¡xmlDoc
.
async
 
=
 
false
;
¡¡¡¡¡¡¡¡xmlDoc ......

¡°XML DOM¶ÁÈ¡½ÚµãÐÅÏ¢¡±Ð¡½á

<?
XML DOM¶ÁÈ¡½ÚµãÐÅÏ¢Óöµ½ÎÊÌâ×ܽ᣺  
 
1:NodeList: ʹÓýڵãµÄchildNodesÊôÐÔ»òÕßdocument¶ÔÏóµÄgetElementsByTagName()·½·¨£¬¾Í»á·µ»ØÒ»¸ö°üº¬½ÚµãÁбíµÄNodeList
 
2: ÔÚ XML DOM ÖУ¬½ÚµãµÄ¹ØÏµ±»¶¨ÒåΪ½ÚµãµÄÊôÐÔ£º
·  parentNode
·  childNodes
· ......

ʲôÊÇxml processing instruction(PI)£¿

from:
http://zhidao.baidu.com/question/67891842.html?si=1
ÏÂÃæµÄÒ»ÐоÍÊÇÔÚµÚ¶þ±¾ÊéµÄ¶¨Òå֮ǰµÄ£º
<?page render multiple authors ?>
ËäÈ»Ëü¿´ÉÏÈ¥ºÜÏñXMLÐòÑÔ£¬µ«Êµ¼ÊÉÏÊÇÒ»ÖÖ³ÆÎª´¦ÀíÖ¸Áprocessing instruction£©µÄ²»Í¬ÀàÐ͵ÄÓï·¨¡£´¦ÀíÖ¸ÁÒÔϼò³ÆPI£©µÄÄ¿µÄÊÇΪÁ˸ø´¦ÀíÒ³ÃæµÄ³ÌÐò£¨ÀýÈçXML½âÎöÆ ......

XML ¸ñʽ

ÏÖÔÚÎÒÃÇÔÝÇÒʹÓÓ¼Çʱ¾”À´´´½¨ÎÒÃǵÄXMLÎļþ°É¡£ÏÈ¿´Ò»¸öXMLÎļþ£º 
¡¡¡¡Àý1 
¡¡¡¡¡´?xml version="1.0" encoding="gb2312" ?¡µ 
¡¡¡¡¡´²Î¿¼×ÊÁÏ¡µ 
¡¡¡¡ ¡´Êé¼®¡µ 
¡¡¡¡ ¡´Ãû³Æ¡µXMLÈëÞ«½â¡´/Ãû³Æ¡µ 
¡¡¡¡ ¡´×÷Õß¡µÕÅÈý¡´/×÷Õß¡ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ