把xml 转dataset
///通过传入的特定XML字符串,通过 ReadXml函数读取到DataSet中。
protected static DataSet GetDataSetByXml(string xmlData)
{
try
{
DataSet ds = new DataSet();
using (StringReader xmlSR = new StringReader(xmlData))
{
ds.ReadXml(xmlSR, XmlReadMode.InferTypedSchema); //忽视任何内联架构,从数据推断出强类型架构并加载数据。如果无法推断,则解释成字符串数据
if (ds.Tables.Count > 0)
{
return ds;
}
}
return null;
}
catch (Exception)
{
return null;
}
}
/// 通过传入的xml文件路径(含文件名),将格式化的Xml文件自动读取转换为DataSet。
public s
相关文档:
ArrayAdapter adapter =
ArrayAdapter.createfromResource(
this,
R.array.catalog,
android.R.layout.simple_list_item_1);
this.setListAdapter(adapter);
xml文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name= ......
已知有一个XML文件(bookstore.xml)如下:
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
<title>Oberon's Legacy</title>
<author>Corets, Eva</author>
&nb ......
我写的第一个程序中写XML的代码执行速度有些问题,改了一下,现在有所改善。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Data.SqlClient;
......
为减少DOM、SAX的编码量,出现了JDOM;
优点:极大减少了代码量。
使用场合:要实现的功能简单,如解析、创建等,但在底层,JDOM还是使用SAX(最常用)、DOM、Xanan文档。
必须得下载jdom.jar文件
package xml.jdom;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOExce ......
1.books.html
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title ......