Linq xml Ê÷¼ÓÔØ×ܽá(1)
¾³£»áÓõ½xmlÎļþ£¬ÄÚÈݼÓÔØ£¬ Èç¹ûʹÓÃlinq xmlÊ÷¼ÓÔØ£¬ÐèҪͨ¹ýXElementÀ࣬һÖÖ·½Ê½ÊÇÒÔ×Ö·û´®µÄÐÎʽ¼ÓÔØ£¬ÁíÍâÒ»ÖÖ·½Ê½ÊÇÒÔÎļþÐÎʽ¼ÓÔØ¡£ 1.ÒÔ×Ö·û´®ÐÎʽ¼ÓÔØ¡£ ÔÚXElementÀàÖУ¬Í¨¹ý¾²Ì¬µÄParse()·½·¨£¬½«XMLÊ÷ÒÔ×Ö·û´®µÄÐÎʽ¼ÓÔص½ÄÚ´æÖУ¬¸ø³öÁËÒ»¸öʵÏÖ´úÂ룺 XElement element =XElement.Parse(xml); xmlÊÇËù°üº¬µÄXMLÊ÷ÄÚÈÝ¡£¿ÉÒÔʵÏÖ½«¸ÃLINQ XMLÊ÷¼ÓÔص½ÄÚ´æÖС£ 2.ÒÔÎļþÐÎʽ¼ÓÔØ¡£ XElement elementfromFile = XElement.Load("myxml.xml"); XELementÀàÖеľ²Ì¬Load()·½·¨£¬ÊµÏÖ½«¸Ãlinq xmlÊ÷¼ÓÔص½ÄÚ´æÖС£
Ïà¹ØÎĵµ£º
import java.io.File;
import java.io.FileNotFoundException;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
public class ResolveXmlFile {
public void resolverXml() throws DocumentException, FileNotFoundExcept ......
±¾ÎÄת×Ô£ºhttp://www.10086web.com/html/wangluobiancheng/Xmlbiancheng/2009/0612/90.html
Ò»¸ö¿Í»§Ìṩһ¸ö¹É¼ÛµÄÐÅÏ¢£¬ÒªÇó·ÅÔÚÒ³ÃæÉÏ£¬ÏÔʾһЩÊý¾Ý£¬ÐèÒª´ÓÔ¶³Ì»ñÈ¡xml£¬È»ºó½âÎöдÔÚÍøÒ³ÉÏ£¬¿ªÊ¼²»»á¾õµÃºÜÄÑ£¬ÆäʵÂù¼òµ¥µÄ£¬ÏÈÓÃjavascriptдÁËÒ»¸ö£º
<mce:script language=javascript><!--
......
×î³£¼ûµÄXMLÊý¾ÝÀàÐÍÓУºElement, Attribute£¬Comment, Text.
Element, Ö¸ÐÎÈç<Name>Tom<Name>µÄ½Úµã¡£Ëü¿ÉÒÔ°üÀ¨£ºElement, Text, Comment, ProcessingInstruction, CDATA, and EntityReference.
Attribute, Ö¸ÔÚ<Employee id=”12345”>ÖеĴÖÌ岿·Ö¡£
&nb ......
×î³£¼ûµÄXMLÊý¾ÝÀàÐÍÓУºElement, Attribute£¬Comment, Text.
Element, Ö¸ÐÎÈç<Name>Tom<Name>µÄ½Úµã¡£Ëü¿ÉÒÔ°üÀ¨£ºElement, Text, Comment, ProcessingInstruction, CDATA, and EntityReference.
Attribute, Ö¸ÔÚ<Employee >ÖеĴ ......