2 Replies - 1021 Views - Last Post: 13 July 2011 - 02:43 PM Rate Topic: -----

#1 deery5000   User is offline

  • D.I.C Lover

Reputation: 87
  • View blog
  • Posts: 1,097
  • Joined: 09-May 09

linq to xml - no results sometimes

Posted 13 July 2011 - 02:16 PM

Hi guys.

Ok i have a query i use to parse an xml file to get an id number of a movie that allows me to get more detailed information about that movie from a database.

Now the problem is the id is returned correctly with xml files stored on my hard drive (c:\desktop\movies)
but when i try and parse an xml file on an external drive it dont get a hit on the <id>1123</id> node.

This is very odd since the code works fine locally.

query
Function movieID(ByVal directory)

        'Get the movie name
        Dim movieTitle() As String
        movieTitle = directory.Split("\")
        Dim i = movieTitle.Count()


        'New document
        Dim doc As XDocument


        If File.Exists(directory) Then

            Try
                'load file into document
                doc = Xdocument.Load(directory)
            Catch ex As Exception
                Return 0
            End Try

        Else
            Return 0
        End If

        'Query XML file movie data 
        Dim movieDetails = From d In doc.Descendants("movie")
                           Where d.Elements("name").Value.Contains(movieTitle(i - 2).ToString)
                           Select Id = d.Element("id").Value




        Return movieDetails(0)
    End Function



xml structure
<movies>
    <movie>
      <score></score>
      <popularity>3</popularity>
      <translated>true</translated>
      <adult>false</adult>
      <language>en</language>
      <original_name>Alice in Wonderland</original_name>
      <name>Alice in Wonderland</name>
      <alternative_name>Alice nel paese delle meraviglie</alternative_name>
      <type>movie</type>
      <id>12155</id>
      <imdb_id>tt1014759</imdb_id>
      <url>http://www.themoviedb.org/movie/12155</url>
      <votes>66</votes>
      <rating>7.2</rating>
      <certification>PG</certification>
      <overview>A 19-year-old Alice journeys through Underland, where she experiences strange ordeals and encounters peculiar characters, including the vaporous Cheshire Cat, the Mad Hatter and the sadistic Red Queen.</overview>
      <released>2010-03-05</released>
      <images>




Any ideas?

works fine on J hdd
access denied on i hdd
above problem on h hdd

Kevin

This post has been edited by deery5000: 13 July 2011 - 02:20 PM


Is This A Good Question/Topic? 0
  • +

Replies To: linq to xml - no results sometimes

#2 AdamSpeight2008   User is offline

  • MrCupOfT
  • member icon

Reputation: 2298
  • View blog
  • Posts: 9,535
  • Joined: 29-May 08

Re: linq to xml - no results sometimes

Posted 13 July 2011 - 02:33 PM

Consider using the XML literal syntax instead. My Blog Post Entry
Was This Post Helpful? 0
  • +
  • -

#3 deery5000   User is offline

  • D.I.C Lover

Reputation: 87
  • View blog
  • Posts: 1,097
  • Joined: 09-May 09

Re: linq to xml - no results sometimes

Posted 13 July 2011 - 02:43 PM

ive read your blog before.

infact you seem to be the only person that ever replies to my ling to xml questions lol

Im asking you do you have any idea why a node wouldnt be found based on the location of the xml file?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1