易截截图软件、单文件、免安装、纯绿色、仅160KB

dom4j 读 xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<company> 
  <tel>020-12345678-66</tel>  
  <tel>020-12345678-85</tel>  
  <introduce> 
  <![CDATA[
<br/><h1>公司简介</h1>
  ]]>
  </introduce>  
</company>
2.用dom4j 读,
package cn.rentbus;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
//import java.io.FileWriter;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import junit.framework.TestCase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.Node;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
public class Dom4jXmlTest extends TestCase {
    protected final Log logger = LogFactory.getLog(getClass());
    
    private SAXReader reader;
    private Document document;
    private File xmlFile;
    
    protected void setUp() throws Exception {
        xmlFile = new File("WEB-INF/company.xml");
        reader = new SAXReader();
        document = reader.read(xmlFile);
    }
    protected void tearDown() throws Exception {
        super.tearDown();
  &n


相关文档:

JAVA对象转换为XML格式

JAVA对象转换为XML格式
    简单的颤述下如何将JAVA对象转换为XML格式,详细了解请进入http://xstream.codehaus.org/tutorial.html
  
 JAVABEAN对象
 
  userInfo.java
         private String name;
   & ......

Integration with the XML Data Type

Integration with the XML Data Type
With the introduction of the XML data type, we wanted to also give FOR XML the ability to generate an instance of XML directly (more precisely, it generates a single row, single column rowset where the cell contains the XML data type instance).
Because of the bac ......

把datatable里的数据转换成xml格式的字符串

string GetXmlByDataTable()
    {
        string xmlstr;
        string sql = "select top 10 * from BasicInfo";
        DataTable dt = idb.ReturnDataTable(sql);
  &nb ......

把文本框的值写入到xml文件中

 protected void btn_write_Click(object sender, EventArgs e)
    {
        XmlWriterSettings settings=new XmlWriterSettings();
        settings.Indent=true;
        setting ......

dom4j对xml比较完整的操作

最近写的插件用到了dom4j,来读写,修改文档。用到的功能都写出来了
下面包含了两个程序 WriteFriendsInfo,和 ReadFriendsInfo。
1.WriteFriendsInfo 包含了新建xml和修改,删除xml节点的方法
 一些要点:
    WriteFriendsInfo 中修改节点采用的方式是删除节点,然后把新的节点写进去。在不对读 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号