DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 8 Aug 2007 15:42:03 -0700,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    pelegk1


xpath and sorting nodes   
i want to get nodes frm an xml using selectNoded,and then to sort them by an 
attribute.
i have found this link :
http://msdn2.microsoft.com/en-us/library/system.xml.xpath.xpathexpression.addsort(vs.71).aspx
which describe how to sort nodes by there attribute value.

i have a xml that loook like this :
<Page>
<MenuLinks>
    <Link isActive="1" innerOrder="4" val2="44">xxxx</Link>
    <Link isActive="1" innerOrder="2" val2="4424">d d d d d </Link>
    <Link isActive="0" innerOrder="14" val2="43244">ssssss</Link>
    <Link isActive="0" innerOrder="44" val2="1144">sdfsdfsdf</Link>
    <Link isActive="1" innerOrder="1"  val2="46664">ertertertert</Link>
  </MenuLinks>
</Page>
and i want to get all of this that :
isActive=1
and ordered by innerOrder!
and get from the relevent nodes there attribute->val2 value
and the text() value of the node?
the code i tried is :


Dim doc As XPathDocument = New XPathDocument("C:\Inetpub\wwwroot\Page.xml")

        Dim nav As XPathNavigator = doc.CreateNavigator()

        'Select all books by Jane Austen.
        Dim expr As XPathExpression
        expr = nav.Compile("Page/MenuLinks/Link/@isActive='1'")

        'Sort the selected books by title.
        expr.AddSort("innerOrder", XmlSortOrder.Ascending, 
XmlCaseOrder.None, "", XmlDataType.Number)

        'Display the selection.
        Dim iterator As XPathNodeIterator = nav.Select(expr)
        While (iterator.MoveNext())
            Dim nav2 As XPathNavigator = iterator.Current.Clone()
            nav2.MoveToFirstChild()
            Console.WriteLine("Book title:  {0}", nav2.Value)
        End While


where do i go wrong?
thnaks in adance
peleg
Date:Wed, 8 Aug 2007 15:42:03 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us