把datatable里的数据转换成xml格式的字符串
string GetXmlByDataTable()
{
string xmlstr;
string sql = "select top 10 * from BasicInfo";
DataTable dt = idb.ReturnDataTable(sql);
dt.TableName = "tbname";
if (dt.Rows.Count>0)
{
System.IO.StringWriter writer = new System.IO.StringWriter();
dt.WriteXml(writer);
xmlstr = writer.ToString();
}
return xmlstr;
}
相关文档:
技术介绍
在一般的Java项目中,生成word文档的时候,我们会使用到jacob来作为我们生成word文档的工具,但是jacob是通过使用JNI调用dll文件来实现,这样的工作方式带来了极大的性能开销.这里我们采用Velocity+zip+xml快速构建word2007文档,所以说这个技术实现有一定的局限性,生成的必须是word2007文档 ......
请看下面的示例:
<person sex="female">
<firstname>Anna</firstname>
<lastname>Smith</lastname>
</person>
<person>
<sex>female</sex>
<firstname>Anna</firstname>
<lastname>Smith</lastname>
</person> ......
Jdom
读取
xml
文件例子
1.
用
JDOM
读取
XML
文件需先用
org.jdom.input.SAXBuilder
对象的
build()
方法创建
Document
对象
,
然后用
Document
类、
Element
类等的方法读取
1.
Sample1.java
import
java.util.*;
import
org.j ......
JAVA对象转换为XML格式
简单的颤述下如何将JAVA对象转换为XML格式,详细了解请进入http://xstream.codehaus.org/tutorial.html
JAVABEAN对象
userInfo.java
private String name;
& ......
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 ......