我现在丛数据库某一个字段取出一个XML格式的字符串
例如: 下面
<?xml version="1.0" encoding="GB2312"?>
<Root>
<Property>
<Name>飞利浦(PHILIPS)分离水箱强力蒸汽电熨斗1200w GC1680</Name>
<Url><a target="_blank" href="http://www.360buy.com/brand/%e9%a3%9e%e5%88%a9%e6%b5%a6.html">飞利浦</a></Url>
<Address>中国</Address>
<Weight>1.30千克</Weight>
<Date>2005-4-11 11:26:28</Date>
</Property>
</Root>然后呢我通过封装在实体对象里面比如 下面XML字符串的字段为 property
而我实体对象为
Product product =new Product();
product.Property =(string)reader.["property"];
通过上面获取到了这个字段,
下面就是我想要实现的功能, 我要把 product.Property 这个字符串转换为XML 格式的,然后去解析XML
最终结果会是这样
(1)飞利浦(PHILIPS)分离水箱强力蒸汽电熨斗1200w GC1680
(2)<a target="_blank" href="http://www.360buy.com/brand/%e9%a3%9e%e5%88%a9%e6%b5%a6.html">飞利浦</a>
(3)中国
(4)1.30千克
(5)2005-4-11 11:26:28最后我会把这5个数据绑定在不同的控件上,比如 textBox
例如: 下面
<?xml version="1.0" encoding="GB2312"?>
<Root>
<Property>
<Name>飞利浦(PHILIPS)分离水箱强力蒸汽电熨斗1200w GC1680</Name>
<Url><a target="_blank" href="http://www.360buy.com/brand/%e9%a3%9e%e5%88%a9%e6%b5%a6.html">飞利浦</a></Url>
<Address>中国</Address>
<Weight>1.30千克</Weight>
<Date>2005-4-11 11:26:28</Date>
</Property>
</Root>然后呢我通过封装在实体对象里面比如 下面XML字符串的字段为 property
而我实体对象为
Product product =new Product();
product.Property =(string)reader.["property"];
通过上面获取到了这个字段,
下面就是我想要实现的功能, 我要把 product.Property 这个字符串转换为XML 格式的,然后去解析XML
最终结果会是这样
(1)飞利浦(PHILIPS)分离水箱强力蒸汽电熨斗1200w GC1680
(2)<a target="_blank" href="http://www.360buy.com/brand/%e9%a3%9e%e5%88%a9%e6%b5%a6.html">飞利浦</a>
(3)中国
(4)1.30千克
(5)2005-4-11 11:26:28最后我会把这5个数据绑定在不同的控件上,比如 textBox
<a>
<b1>
<c>ccc</c>
<d>ddd</d>
</b1>
<b2>
<e>eee</e>
<f>fff</f>
</b2>
</a>
private string GetInfoByXML(string xmlFilePath,string nodeName) // xmlFilePath是xml的文件名,nodeName是你要查询的节点的名称,就是c
{
document.Load(xmlFilePath);
string result = string.Empty;
try
{
XmlNodeList nodeList = document.SelectSingleNode("a").ChildNodes;
if (nodeList != null && nodeList[0].ChildNodes != null)
{
foreach (XmlNode xn in nodeList[0].ChildNodes)
{
if (xn.Name == nodeName)
{
result = xn.InnerText;
break;
}
}
}
return result;
}
catch (Exception ex)
{
}
}
然后我要取这个字符串出来,转换为XML 然后再读取里面的内容信息
请楼上的看好题目再帮下忙了谢谢!!!!!!!!!!!!