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
 
Back
Top