我的页面上有一个XmlDataSource和一个GridView。在Page_Load事件中,我应用XPath根据用户的输入过滤xml元素,LexiqueXmlDataSource.XPath = 'Some_XPath_here';
并且它工作正常。循环通过XmlDataSource中的XML元素后面的代码
我想要的是访问XmlDataSource在应用XPath表达式(从而得到它们的编号)后从代码隐藏中返回的元素。
我试过GetXmlDocument()
方法,但它返回的是整个原始的Xml文件,而不是使用XPath过滤的元素。
编辑:
这里是一些代码和情景我想:
protected void Page_Load(object sender, EventArgs e)
{
string xpath = "/lexique/item[starts-with(@acronym, '" + filter + "')]";
LexiqueXmlDataSource.XPath = xpath;
// Here the XmlDataSource have filtered the xml elements to return to the GridView
//I want to know how many element passed this filter using the XmlDataSource itself
}
谢谢。
不`计数(your_expression_here)`工作? – Flack 2011-02-12 22:36:39
我想从XmlDataSource访问元素,而不是自己访问xml文件 – 0xFF 2011-02-12 22:49:44
我认为还不清楚......您是否想访问“Page_Load”事件中的选定节点,但是不需要再次查询XML源?那么你不需要XPath表达式。重新标记 – 2011-02-12 23:19:44