我要查询 :
条件:title='Harry Potter' 一定要注意,title值有单引号如何处理
目标:book的属性@category值是多少
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en">'Everyday Italian'</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book><book category="CHILDREN">
<title lang="en">'Harry Potter'</title>
<title lang="en">Everyday Italian</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>已经有的方法using System.Xml;
using System.Xml.XPath; public string GetData(string strsql)
{
XPathNavigator nav;
XPathDocument docNav;
XPathNodeIterator NodeIter; string strRetrun = string.Empty;
nav = docNav.CreateNavigator();
strExpression = "";//在这儿写查询语句
MessageBox.Show(strExpression);
NodeIter = nav.Select(strExpression);
while (NodeIter.MoveNext())
{
strRetrun += NodeIter.Current.Value;
};
return strRetrun;
}
或者给更好的建议
条件:title='Harry Potter' 一定要注意,title值有单引号如何处理
目标:book的属性@category值是多少
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en">'Everyday Italian'</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book><book category="CHILDREN">
<title lang="en">'Harry Potter'</title>
<title lang="en">Everyday Italian</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>已经有的方法using System.Xml;
using System.Xml.XPath; public string GetData(string strsql)
{
XPathNavigator nav;
XPathDocument docNav;
XPathNodeIterator NodeIter; string strRetrun = string.Empty;
nav = docNav.CreateNavigator();
strExpression = "";//在这儿写查询语句
MessageBox.Show(strExpression);
NodeIter = nav.Select(strExpression);
while (NodeIter.MoveNext())
{
strRetrun += NodeIter.Current.Value;
};
return strRetrun;
}
或者给更好的建议
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货