XPath AddSort Question

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
 
T

Teemu Keiski

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top