XML£¬XMLList
5. ÃüÃû¹æÔò£¨²»ÄÜ°üÀ¨ xml£¬¿Õ¸ñ£¬¼âÀ¨ºÅ£¬µÈÌØÊâ·ûºÅ£¬²»ÄÜÊý×Ö¿ªÍ·£©
6. ¿ÉÒÔ×Ô´øÊôÐÔ¡£ÊôÐÔÖµÓÓ”±êʾ
7. ×¢ÊÍ<!--×¢Ê͵ÄÄÚÈÝ-->
8. Èç¹ûÒªÏÔʾÌØÊâ·ûºÅ¿ÉÓÃ<![CDATA[ ÕâÀïдÌØÊâ·ûºÅ ]]>
´´½¨
var xml:XML=<shuiGuo>
<apple price="1.5">ºìÆ»¹û</apple>
<apple price="1.6">ÇàÆ»¹û</apple>
<apple price="1.8">»ÆÆ»¹û</apple>
<orange price="1.0">éÙ×Ó</orange>
</shuiGuo>;//×¢ÒâÕâÀïµÄ·ÖºÅ²»¿ÉÊ¡ÂÔ
»òÕß
var xml:XML=new XML(“xml¸ñʽ×Ö·û´®”)
ͨ³£ÓÃÀ´¶ÁÈ¡ÍⲿµÄ xml Îļþ
²Ù×÷£º£¨· @ ·· * delete£©
trace(xml.*.(@price<1.9))
delete xml.orange[1];
xml.banana=<banana price="2.5">"Ï㽶"</banana>
xml.banana.pear="Àæ"
Àý×Ó£º
var xml:XML=<fruit>
<apple price="1.5">ºìÆ»¹û</apple>
<apple price="1.6">ÇàÆ»¹û</apple>
<apple price="1.8">»ÆÆ»¹û</apple>
<orange price="2.0">éÙ×Ó</orange>
</fruit>;
var appleList:XMLList=xml.apple;
var len:uint=appleList.length();
for (var i=0; i<len; i++) {
dyg_mc.name_txt.text=appleList[i];
dyg_mc.price_txt.text=appleList[i].@pric
Ïà¹ØÎĵµ£º
MSXML2::IXMLDOMDocumentPtr pDoc;
MSXML2::IXMLDOMElementPtr xmlRoot ;
// ´´½¨DOMDocument¶ÔÏó
HRESULT hr = pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument40));
if ( ! SUCCEEDED(hr))
{
MessageBox( " ÎÞ·¨´´½¨DOMDocument¶ÔÏó£¬Çë¼ì²é ......
Ò»£ºÉè¼Æģʽ²¿·Ö
״̬ģʽ£¨state£©
״̬ģʽÀàËÆÓÚÒ»ÖÖ¼òµ¥µÄ¹¤×÷Á÷£¬ÓÃÀ´°Ñ´óÁ¿µÄÅжϷÖÖ§½øÐвð·Ö£¬¸øÿһÖÖÅжÏÔö¼ÓÒ»¸ö״̬£¬Èç¹û²»Âú×ã¸ÃÅжϿÉÒÔ½øÐÐ״̬ת»»£¬ÖªµÀÓöµ½Âú×ãÌõ¼þΪֹ
ÕâÑù×öµÄºÃ´¦¾ÍÊÇ£¬µ±ÐèÒªÔö¼ÓÅжϵÄʱºò£¬²»ÐèÒª¸Ä±äÒѾ´æÔڵĴúÂë¡£Ö»ÐèÒªÔö¼ÓÅжϵÄÀ࣬ÔʼÅжÏÀàÖÐÔö¼ÓеÄ״̬ת»»¡£
Ê ......
package com.test.dom4j;
import java.io.*;
import java.util.*;
import org.dom4j.*;
import org.dom4j.io.*;
public class MyXMLReader {
public static void main(String arge[]) {
try {
File f = new File("src/testxml.xml");
SAXReader reader = new SAXReader();
Document doc = reader.rea ......
Ç°¶Îʱ¼ä¸ø¿Í»§×öÁ˼¸¸öÍøÒ³£¬¿Í»§ÒªÇóÔÚ×Ô¼ºµÄÍøÕ¾ÖÐÏÔʾ×Ô¼ºÔÚÐÂÀ˲©¿ÍÀïµÄÎÄÕ£¬×÷ΪÍøÕ¾µÄÒ»²¿·Ö¡£ÕâÑùµÄÇé¿ö¿ÉÒÔ½â¾ö£¬Ö÷Òª¿ÉÒÔͨ¹ý²©¿ÍÖÐµÄ XMLÀ´ÊµÏÖ£¬Í¨¹ýÓÃaspÀ´¶ÁÈ¡²©¿ÍÖÐXML£¬½«²©¿ÍÖеıêÌâ¡¢·¢²¼Ê±¼äµÈÐÅÏ¢ÏÔʾÔÚÍøÕ¾ÖС£µ«ÊÇÔÚʹÓõĹý³ÌÖУ¬³öÏÖÁËÒ»¸öÎÊÌ⣺µ±²©¿ÍÖÐÌí¼ÓÎÄÕºó£¬ÔÚÍøÒ³ÖжÁÈ¡²©¿ÍÖеÄXMLºó½ ......
ÏÂÃæµÄÄÚÈÝ£¬ÎÒÃǽ«¸ü¶àµÄ¹Ø×¢DOM£¬ÎªDOM×÷Ò»¸ö½ÏΪÏêϸµÄ½âÎö£¬Ê¹ÎÒÃÇʹÓÃÆðÀ´¸üΪµÃÐÄÓ¦ÊÖ¡£
DOMÏê½â
1£®»ù±¾µÄDOM¶ÔÏó
DOMµÄ»ù±¾¶ÔÏóÓÐ5¸ö£ºDocument£¬Node£¬NodeList£¬ElementºÍAttr¡£ÏÂÃæ¾ÍÕâЩ¶ÔÏóµÄ¹¦ÄܺÍʵÏֵķ½·¨×÷Ò»¸ö´óÖµĽéÉÜ¡£
Document¶ÔÏó´ú±íÁËÕû¸öXMLµÄÎĵµ£¬ËùÓÐÆäËüµÄNode£¬¶¼ÒÔÒ»¶¨µÄ˳Ðò°üº ......