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

ÓÃSAXReader½âÎöxmlÎĵµ

     ʹÓÃSAXReaderÐèÒªµ¼Èëdom4j-full.jar°ü¡£
     dom4jÊÇÒ»¸öJavaµÄXML API£¬ÀàËÆÓÚjdom£¬ÓÃÀ´¶ÁдXMLÎļþµÄ¡£dom4jÊÇÒ»¸ö·Ç³£·Ç³£ÓÅÐãµÄJava XML API£¬¾ßÓÐÐÔÄÜÓÅÒì¡¢¹¦ÄÜÇ¿´óºÍ¼«¶ËÒ×ÓÃʹÓõÄÌص㣬ͬʱËüÒ²ÊÇÒ»¸ö¿ª·ÅÔ´´úÂëµÄÈí¼þ£¬¿ÉÒÔÔÚSourceForgeÉÏÕÒµ½Ëü¡£
     ʹÓþÙÀý£º
1.    s.xmlÄÚÈÝ
<?xml version="1.0" encoding="GB2312"?>
<data>
<row queryDTO.enterpriseId="gfd" queryDTO.loginName="gdfg" queryDTO.state="0"/>
</data>

2.½âÎö
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Iterator;
import java.util.List;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.dom4j.tree.AbstractAttribute;
public class ReadXMLTest {

public static void main(String[] args){
File xmlFile = new File("C:/s.xml");
FileInputStream fis = null;
try {
fis = new FileInputStream(xmlFile);
} catch (FileNotFoundException e) {
e.printStackTrace();
System.err.println("File is not exsit!");
}

SAXReader saxReader = new SAXReader();
List rowList = null;
try {
//Éú³ÉÎĵµ¶ÔӦʵÌå
Document doc = saxReader.read(fis);
//»ñÈ¡Ö¸¶¨Â·¾¶ÏµÄÔªËØÁбí,ÕâÀïÖ¸»ñÈ¡ËùÓеÄdataϵÄrowÔªËØ
rowList = doc.selectNodes("//data/row");
} catch (DocumentException e) {
e.printStackTrace();
}


for(Iterator iter = rowList.iterator();iter.hasNext();){
//»ñµÃ¾ßÌåµÄrowÔªËØ
Element element = (Element)iter.next();
//»ñµÃrowÔªËصÄËùÓÐÊôÐÔÁбí
List elementList = element.attributes();
for(Iterator iter1 = elementList.iterator();iter1.hasNext();){
//½«Ã¿¸öÊôÐÔת»¯ÎªÒ»¸ö³éÏóÊôÐÔ£¬È»ºó»ñÈ¡ÆäÃû×ÖºÍÖµ
AbstractAttribute aa = (AbstractAttribute)iter1.next();
System.out.println("Name:"+aa.getName


Ïà¹ØÎĵµ£º

OpenXml¿ª·¢ Ò»¸öÓ¦ÓÃXmlµÄÀý×Ó


  3private XmlDocument xmlDoc;
  4        //load xml file
  5        private void LoadXml()
  6        { ......

DelphiÓëXMLÎĵµ

ͬ²½³ÌÐò°¸Àý
procedure TGetOrderThread.PostDB(webnr:WideString);
var
  Err: String;
  SetWebnr:WideString;
  xmlDoc: IXMLDocument;
  root: IXMLNode;
  rowc: IXMLNode;//¼Ç¼Êý
  rows: IXMLNodeList;//Ö÷¼Ç¼Áбí
  row: IXMLNode;
  drows: IXMLNodeList;// ......

xml½âÎö


ÔÚjavaÓ¦Óÿª·¢ÖÐÎÒÃǺÍxml´ò½»µÀµÃ»ú»á̫ƽ·²ÁË£¬Ò»°ãÇé¿öÏÂÎÒ¿´»áÓÃJDOM»òÊÇDOM4jÀ´½âÎöÎÒÃǵÃXMLÎļþ£¬ÏÂÃæÊÇÒ»¸öDom4j½âÎöxmlÎļþµÃÀý×Ó£¬ÆäÖаüÀ¨Á˶ÔxmlÎļþµÃÈ¡Öµ¡¢¸³Öµ¡¢ÌáÈ¡½Úµã¡¢½ÚµãµÃ±éÀúµÈ¡£
SAXReader reader =
new
SAXReader();   
Document doc = reader.read(...);  &nb ......

¸ñʽ»¯XMLÊä³ö

ËäÈ»XMLÉè¼ÆµÄ³õÖÔÊÇΪÁË·½±ã»úÆ÷Ö®¼äµÄ½»»¥£¨interoperability£©£¬¶øÐèÒªÂú×ã»úÆ÷¿ÉÔĶÁ£¨machine readable£©µÄÌØÐÔ¡£È»¶ø£¬ÓÉÓÚ³ÌÐòԱΪÁË·½±ã¿ª·¢£¬¼ÈÈ»XMLÊÇͨ¹ýÎı¾±íʾµÄ£¬²»ÈçÔÙÇ¿»¯Ò»Ð©£¬×öµ½ÈËÀà¿ÉÔĶÁ£¨human readable£©°É¡£XML¾¿¾¹ÊÇÄÄÖÖ¿ÉÔĶÁµÄÌÖÂÛÒѾ­ÊÇÀÏÉú³£Ì¸ÁË£¬ÕâÀï²»»áÉîÈë̽ÌÖ£¬Ö»ÊǽèÖúÕâ¸ö»ú»á½éÉÜÒ ......

jms xml namespace

<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:amq="http://activemq.org/config/1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/bea ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ