XPath AddSort Question

  • Thread starter Thread starter DN
  • Start date Start date
D

DN

I'd like to pass multiple attributes to XPath AddSort like:

expr = nav.Compile(strQuery);
expr.AddSort(sortArray, XmlSortOrder.Ascending, XmlCaseOrder.None, "",
XmlDataType.Text);

But I get "Only objects returned from Compile() can be passed as input."

It works fine with a single field name or attribute, but I can't seem to
figure out how to pass multiple fields.

Any ideas?

Thanks
 
Hi,

you would need to concatenate the contents of multiple nodes using XPath's
concat function to create an XPath expression to be passed to the AddSort.
For example to sort by last name and first name

string key="concat(concat(lastname,','),firstname)";

Then pass this to the AddSort method. It will be evaluated as a string and
actual value will be used to sort nodes.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist


I'd like to pass multiple attributes to XPath AddSort like:

expr = nav.Compile(strQuery);
expr.AddSort(sortArray, XmlSortOrder.Ascending, XmlCaseOrder.None, "",
XmlDataType.Text);

But I get "Only objects returned from Compile() can be passed as input."

It works fine with a single field name or attribute, but I can't seem to
figure out how to pass multiple fields.

Any ideas?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

XPathNavigator.Select 1
XPath help needed 10
XmlDataSource XPath question 1
Need XPath help 2
Need help with xpath and xml 2
XPath question 2
C# XPath 5
C# - XPath, XMLDataSource and a DataGridView 5

Back
Top