Linq to XML - Returns nothing in the for loop

query returns nothing , VB.NET , Linq to XML Houston, United States
  • 10 years ago

    I have a XML file on which when I run a Linq query returns nothing in the for loop. 1 10 18033 true false 2010-07-25T01:37:04.067Z

    Dim document As XDocument = XDocument.Parse(myOrders.xml) Dim query = From O In document.Root.Elements("OrderList") _ Select New With _ { _ .Archived= O.Element("Archived").Value, _ .Status = O.Element("CreateDate").Value _ }

                    For Each Order In query
                        Console.WriteLine(Order.Archived)
                        Console.ReadLine()
                    Next
    

    It does not even go inside the for loop. What am I doing wrong? Thanks Sajjad

  • 10 years ago

    I have a XML file on which when I run a Linq query returns nothing in the for loop. " 1 10 18033 true false 2010-07-25T01:37:04.067Z "

    Dim document As XDocument = XDocument.Parse(myOrders.xml) Dim query = From O In document.Root.Elements("OrderList") _ Select New With _ { _ .Archived= O.Element("Archived").Value, _ .Status = O.Element("CreateDate").Value _ }

                    For Each Order In query
                        Console.WriteLine(Order.Archived)
                        Console.ReadLine()
                    Next
    

    It does not even go inside the for loop. What am I doing wrong? Thanks Sajjad

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“If debugging is the process of removing software bugs, then programming must be the process of putting them in.” - Edsger Dijkstra