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

JDOM生成XML文档

首先下载JDOM.JAR加入的classpath中
package com.test.search;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.output.XMLOutputter;
public class ToXML {
public void BuildXMLDoc(List<SearchBean> list) throws IOException, JDOMException {
//创建跟节点
Element root=new Element("search");

//将跟节点添加到文档中
Document document=new Document(root);
for (int i = 0; i < list.size(); i++) {
SearchBean bean=list.get(i);
Element element=new Element("object");
element.addContent(new Element("URL").setText(bean.getUrl()));
element.addContent(new Element("TITLE").setText(bean.getTitle()));
element.addContent(new Element("DESCRIBE").setText(bean.getDiscribe()));
element.addContent(new Element("INFO").setText(bean.getInfo()));

root.addContent(element);
}
XMLOutputter out=new XMLOutputter();

out.output(document, new FileOutputStream("search.xml"));
}
/*public static void main(String[] args) {
ToXML toXML=new ToXML();

}*/
}

生成完成,只是生成的xml文档的节点有点乱,不是树型的。


相关文档:

php之XML转数组函数

<?
/**
* xml2array() will convert the given XML text to an array in the XML structure.
* Link: http://www.bin-co.com/php/scripts/xml2array/
* Arguments : $contents - The XML text
* $get_attributes - 1 or 0. If this is 1 the function will get the attributes as well as the ......

Delphi与XML文档

同步程序案例
procedure TGetOrderThread.PostDB(webnr:WideString);
var
  Err: String;
  SetWebnr:WideString;
  xmlDoc: IXMLDocument;
  root: IXMLNode;
  rowc: IXMLNode;//记录数
  rows: IXMLNodeList;//主记录列表
  row: IXMLNode;
  drows: IXMLNodeList;// ......

missing } in XML expression

本次遇到的问题是:在上传文件时,返回的json数据被加上了<pre></pre>标签。(在普通的表单提交并不会加上<pre>标签)
利用firebug查看错误信息为:
missing } in XML expression  (<pre>{success:true, msg:'成功'}</pre>)
对此问题解决如下:
对response对象设置返回类型:resp.s ......

python minidom 写xml示例

以下是一个通过minidom模块写文件的完整示例,是在最近做的项目Walle上面用到的,这个示例的目的是生成一个如下的格式的xml,文件格式为无BOM utf-8。
生成xml文件格式:
<?xml version="1.0" encoding="utf-8"?> 
<coverages> 
    <coverage> 
    ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号