以下のようなXMLファイルがあります
<?xml version="1.0" standalone="yes"?>
<ShippersDataSet xmlns="http://www.tempuri.org/ShippersDataSet.xsd">
<Shippers>
<ShipperID>1</ShipperID>
<CompanyName>Speedy Express</CompanyName>
<Phone>(503) 555-9831</Phone>
</Shippers>
<Shippers>
<ShipperID>2</ShipperID>
<CompanyName>United Package</CompanyName>
<Phone>(503) 555-3199</Phone>
</Shippers>
<Shippers>
<ShipperID>3</ShipperID>
<CompanyName>Federal Shipping</CompanyName>
<Phone>(503) 555-9931</Phone>
</Shippers>
</ShippersDataSet>
XML データに対して次の入力があります。
string XMLpath, string query
クエリ:
<Query>
<ElementPath> Shippers</ElementPath>
</Query>
追加する必要があります
次のように、(私はSQLで達成しました)XMLデータに追加する必要があるのと同じ方法
var list = new List<Myclassdef>();
using (var con = new SqlConnection(Settings.Default.ConnectionString))
{
using (var cmd = new SqlCommand("SELECT ... WHERE Col1=@param1", con))
{
cmd.Parameters.AddWithValue("@param1", "value1");
// ...
con.Open();
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
Myclassdef data = new Myclassdef();
data.Data = new Dictionary<string, object>();
for (int i = 0; i < reader.FieldCount; i++)
{
data.Data.Add(reader.GetName(i), reader[i]);
}
list.Add(data);
}
}
}
}
XML データに対して次の入力があります。
string XMLpath, string query
クエリ:
<Query><ElementPath> Shippers</ElementPath></Query>