![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
How do I create an xpath expression to return a sorted nodelist? |
#3
| |||
| |||
|
|
Lou wrote: How do I create an xpath expression to return a sorted nodelist? See <URL:http://msdn2.microsoft.com/en-us/library/b2hhe5h7.aspx> for the AddSort method on XPathExpression. |
#4
| |||
| |||
|
|
Lou wrote: How do I create an xpath expression to return a sorted nodelist? See <URL:http://msdn2.microsoft.com/en-us/library/b2hhe5h7.aspx> for the AddSort method on XPathExpression. -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ |
#5
| |||
| |||
|
|
Here is my code where the iterator.Current.Value returns empty strings. ================================================= 'Construct the XPathDocument by specifying the path to Books.xml. Dim xmldoc As New System.Xml.XPath.XPathDocument(ElectionData.DataFi le) 'Create XPathNavigator. Dim nav As System.Xml.XPath.XPathNavigator = xmldoc.CreateNavigator() 'Compile the XPath query expression to select all the Title elements. 'The Compile method of the XPathNavigator generates an XPathExpression 'object that encapsulates the compiled query. Dim expr As System.Xml.XPath.XPathExpression = nav.Compile("xml/rnames/name/[@lastName]") |
|
'Execute the AddSort method of the XPathExpression object to define the ' Title Element as the sort key. expr.AddSort(".", System.Xml.XPath.XmlSortOrder.Ascending, System.Xml.XPath.XmlCaseOrder.None, "", Xml.XPath.XmlDataType.Text) |
#6
| |||
| |||
|
|
Martin Honnen wrote: Lou wrote: How do I create an xpath expression to return a sorted nodelist? See <URL:http://msdn2.microsoft.com/en-us/library/b2hhe5h7.aspx> for the AddSort method on XPathExpression. Here is an example: Dim doc As XPathDocument = New XPathDocument("..\..\XMLFile1.xml") Dim nav As XPathNavigator = doc.CreateNavigator() Dim ex1 As XPathExpression = XPathExpression.Compile("*/name") ex1.AddSort("@lastName", XmlSortOrder.Ascending, XmlCaseOrder.LowerFirst, "en", XmlDataType.Text) Dim it As XPathNodeIterator = nav.Select(ex1) While it.MoveNext() Console.WriteLine(it.Current.GetAttribute("lastNam e", "")) End While -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |