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

怎样将XML的Document 转换成 String

import java.io.StringWriter;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.apache.xerces.dom.DocumentImpl;
import org.apache.xerces.dom.DOMImplementationImpl;
import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.Serializer;
import org.apache.xml.serialize.XMLSerializer;
public class HelloApache
{
  public static void main (String[] args)
  {
    try
    {
      Document doc = new DocumentImpl();
      // Create Root Element
      Element root = doc.createElement("BOOK");
      // Create 2nd level Element and attach to the Root Element
      Element item = doc.createElement("AUTHOR");
    
item.appendChild(doc.createTextNode("Bachelard.Gaston"));
      root.appendChild(item);
      // Create one more Element
      item = doc.createElement("TITLE");
      item.appendChild(doc.createTextNode
                        ("The Poetics of Reverie"));
      root.appendChild(item);
      item = doc.createElement("TRANSLATOR");
      item.appendChild(doc.createTextNode("Daniel
Russell"));
      root.appendChild(item);
      // Add the Root Element to Document
      doc.appendChild(root);
      //Serialize DOM
      OutputFormat format    = new OutputFormat (doc);
      // as a String
      StringWriter stringOut = new StringWriter (); &nb


相关文档:

如何 使用 java 操纵 XML 文件


Introduction to XML and XML With Java  
 
If you are looking for sample programs to parse a XML file using DOM/SAX parser or looking for a program to generate a XML file please proceed directly to programs.
This small tutorial introduces you to the basic concepts of XML and using Xer ......

JAVA 中用XML实现INI文件格式的解决方案

        这篇文章被转载的次数最多,其实代码简陋得我自己都看不下去。只不过发表这篇文章时很多人需要这个功能。
     
      这几天写个数据库查询分析器,要用到XML记录用户注册的数据库连接地址、端口等信息,最开始想用java ......

SQLServer2005分解并导入xml文件

  SQLServer2005分解并导入xml文件 收藏
测试环境SQL2005,windows2003
DECLARE @idoc int;
DECLARE @doc xml;
 
SELECT @doc=bulkcolumn from OPENROWSET(
   BULK 'D: \test.xml',
   SINGLE_BLOB) AS x
 
EXEC sp_xml_preparedocument @Idoc OUTPUT, @doc
 
  ......

xml operation

package demo.oath ;
import org.jdom.* ;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class AccountHelper
{
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号