ÓÃDom4J½âÎö´øÃüÃû¿Õ¼äµÄXMLÎļþ
Dom4JÊÇÒ»¸ö¿ªÔ´µÄÓÅÐãµÄXML½âÎöAPI£¬ÏÖÔÚÔ½À´Ô½¶àµÄÏîÄ¿ÖпªÊ¼²ÉÓÃÕâÖÖ½âÎö·½Ê½£¬ÆäÖаüº¬ÁËÖøÃûµÄHibernate¡£ÕâÀïÎÒÃÇʹÓÃDom4J½âÎöÒ»¸ö´øÃüÃû¿Õ¼äµÄCXFµÄSpringÅäÖÃÎļþ¡£Ïȵ¼Èëdom4j-1.6.1.jar
spring ÅäÖÃÎļþ applicationContext-cxf.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd"
default-autowire="byName" default-lazy-init="true">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<bean id="jaxWsServiceFactoryBean" class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean" scope="prototype">
<property name="wrapped" value="true"/>
<property name="dataBinding" ref="aegisBean"/>
<property name="serviceConfigurations">
<list>
<bean class="org.apache.cxf.jaxws.support.JaxWsServiceConfiguration"/>
<bean class="org.apache.cxf.aegis.databinding.AegisServiceConfiguration"/>
<bean class="org.apache.cxf.service.factory.DefaultServiceConfiguration"/>
</list>
</property>
</bean>
<bean id="aegisBean" class="org.apache.cxf.aegis.databinding.AegisDatabinding"/>
<jaxws:endpoint id="WSpersonService" implementor="#personService" address="/PersonService">
<jaxws:serviceFactory>
Ïà¹ØÎĵµ£º
ʹÓÃXMLList¶ÁÈ¡XMLÊý¾Ý
¡¡¡¡XML¶ÔÏóÌṩÁËÒ»¸ö·µ»ØXMLListÀàÐ͵ķ½·¨elements()£¬¼È·µ»ØËùÓÐXML¶ÔÏóµÄ×ÓÔªËØ½Úµã£¬ËæºóÎÒÃÇ¿ÉÒÔͨ¹ýfor eachÓï¾äÑ»·Ôò¿É·ÃÎʵ½Õû¸öXMLÊý¾ÝÄÚÈÝ¡£ÒÔÉÏÃæ´´½¨ÄÚ²¿XMLÎĵµµÄXMLÊý¾ÝΪÀý£¬Ïêϸ¼ûÈçÏ´úÂë¿é£º
varlist:XMLList=pXml.elements();
foreach(varelement:XMLinlist)
{
¡¡¡¡// ......
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE hibernate-configuration (View Source for full doctype...)>
- <!-- Generated by MyEclipse Hibernate Tools.
--> - <!-- ÒÔÉϼ¸ÐÐËùÓеÄhibernate.cfg.xml¶¼Ïàͬ
--> [url=file:///C:/Documents%20and%20Settings/ ......
Ò».Éú³Édocument¶ÔÏó¡£
import org.jdom.*;
import org.jdom.input.SAXBuilder;
public class ReportDocUtil {
public ReportDocUtil() {
}
/**
* <p>Description:covert xml file to Document</p>
* @param url ¸ñʽxmlÎļþµÄ´æ·ÅµÄÏà¶Ô·¾¶
& ......
XMLÎļþµÄ½âÎö££libxml¿âº¯Êý½âÊÍ
ÕªÒª
LibxmlÊÇÒ»¸öÓÐÃâ·ÑÐí¿ÉµÄÓÃÓÚ´¦ÀíXML¡¢¿ÉÒÔÇáËÉ¿çÔ½¶à¸öƽ̨µÄCÓïÑÔ¿â¡£Õâ¸öÖ¸ÄÏÌṩËüµÄ»ù±¾º¯ÊýµÄÀý×Ó¡£
Ð÷ÂÛ
Libxml ÊÇÒ»¸öʵÏÖ¶Á¡¢´´½¨¼°²Ù×ÝXMLÊý¾Ý¹¦ÄܵÄCÓïÑÔ¿â¡£Õâ¸öÖ¸ÄÏÌṩÀý×Ó´úÂë²¢¸ø³öËü»ù±¾¹¦ÄܵĽâÊÍ¡£ÔÚÕâ¸öÏîÄ¿µÄÖ÷Ò³ÉÏÓÐLibxml¼°¸ü¶à¹ØÓÚËü¿ÉÓõÄ×ÊÁÏ¡ ......
JAVA²Ù×÷XMLµÄÍêÕûÀý×Ó——W3C DOM
JAVA²Ù×÷XMLµÄÍêÕûÀý×Ó——W3C DOMƪÊÕ²Ø
ÕâÊÇÒ»¸öÓÃJAVA W3C DOM ½øÐÐXML²Ù×÷µÄÀý×Ó£¬°üº¬Á˲éѯ¡¢Ôö¼Ó¡¢Ð޸ġ¢É¾³ý¡¢±£´æµÄ»ù±¾²Ù×÷¡£½ÏÍêÕûµÄÃèÊöÁËÒ»¸öXMLµÄÕû¸ö²Ù×÷Á÷³Ì¡£ÊʺϸÕÈëÃÅJAVA XML²Ù×÷µÄÅóÓѲο¼ºÍѧϰ¡£
¼ÙÉèÓÐXMLÎļþ£ºtest1.xml
<?xml v ......