分不多..求帮助
求帮助..新人分不多..我将一个类串行化后.如何将串行化得到的XML..直接存入数据库.而不是写入一个文件
public class product
{
private int prodId = 123;
private string prodName = "YELLOW";
private bool discont;
[XmlAttributeAttribute(AttributeName = "ProdId")]
public int prodIdValue
{
get { return prodId; }
set { prodId = value; }
}
[XmlElementAttribute()]
public string prodNameValue
{
get { return prodName; }
set { prodName = value; }
}
[XmlElementAttribute()]
public bool discontValue
{
get { return discont; }
set { discont = value; }
}
public string ffshow()
{
return "asdfasdf";
}
}
protected void Page_Load(object sender, EventArgs e)
{
product pd = new product();
TextWriter tr = new StreamWriter(@"c:\serialprod.xml");
TextReader treader = new StreamReader();
XmlSerializer sr = new XmlSerializer(typeof(product));
sr.Serialize(tr,pd);
tr.Close();
}
sr.Serialize只能用STREM XMLWRITER TEXTWRITER...
谢谢
--------------------编程问答-------------------- 顶 --------------------编程问答-------------------- <?xml version="1.0" encoding="utf-8"?>
<product xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<prodIdValue>123</prodIdValue>
<prodNameValue>YELLOW</prodNameValue>
<discontValue>false</discontValue>
</product>
着个是串行化后得到的XML..
如果以后还有新的类串行化后得到新的XML.如何假如到这个XML
<product xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CLASS1>
<prodIdValue>123</prodIdValue>
<prodNameValue>YELLOW</prodNameValue>
<discontValue>false</discontValue>
</CLASS1>
<CLASS2>
...............
</CLASS2>
</product> --------------------编程问答-------------------- 顶…… --------------------编程问答-------------------- 不会 啊 ……
我也是初学者
……
学习中…… --------------------编程问答-------------------- ...继续等待.... --------------------编程问答-------------------- ...没人看啊..这么是不是分太少了? --------------------编程问答-------------------- 将要存储这个xml串的数据库表的字段的类型设置成text类型 --------------------编程问答--------------------
补充:.NET技术 , C#