New Posts  All Forums:Forum Nav:

C# LINQ XML Question!

post #1 of 3
Thread Starter 
Hey, i'm trying to search the spotify database for music, but i have come over a problem. When i try to read this value:
Code:
<track href="spotify:track:1PqUoAoFZzgsQejdnCOJ5T"> value,
It gives me the following error
"Additional information: Object reference not set to an instance of an object."

But when i remove
xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.spotify.com/ns/music/1"

from the first line, it works perfectly why?
How can i fix this?
Code:
<tracks xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.spotify.com/ns/music/1">
<opensearch:Query role="request" startPage="1" searchTerms="yolo"/>
<opensearch:totalResults>528</opensearch:totalResults>
<opensearch:startIndex>0</opensearch:startIndex>
<opensearch:itemsPerPage>100</opensearch:itemsPerPage>
<track href="spotify:track:1PqUoAoFZzgsQejdnCOJ5T">
<name>YOLO</name>
<artist href="spotify:artist:1f5GqyOPo0CkotzzRwviBu">
<name>The Lonely Island</name>
</artist>
<artist href="spotify:artist:4bYPcJP5jwMhSivRcqie2n">
<name>Adam Levine</name>
</artist>
<artist href="spotify:artist:2YZyLoL8N0Wb9xBt1NhZWg">
<name>Kendrick Lamar</name>
</artist>
<id type="isrc">USUM71300756</id>
<album href="spotify:album:4JdzNht5hRTYqTDLS6tlXS">
<name>YOLO</name>
<released>2013</released>
<availability>
<territories>
AR AT AU BE BG BO BR CH CL CO CR CY CZ DE DK DO EC EE ES FI FR GB GR GT HK HN HU IE IS IT LT LU LV MT MY NI NL NO NZ PA PE PH PL PT PY RO SG SI SK SV TR TW UY
</territories>
</availability>
</album>
<track-number>1</track-number>
<length>189.001000</length>
<popularity>0.59</popularity>
</track>
http://ws.spotify.com/search/1/track?q=yolo

My Code:
Code:
XDocument xdoc = XDocument.Load("C:/Users/Dulki/Desktop/testxml.xml");
 string spotifysearch = xdoc.Root.Element("track").Attribute("href").Value;
 MessageBox.Show(spotifysearch);

Edited by TheDulki - 1/2/14 at 7:51am
My Computer ...
(11 items)
 
  
CPUMotherboardGraphicsRAM
AMD Phenom ii x4 955 @4ghz M4A88T-M/USB3 ASUS HD6870 DirectCU 4GB ValueRam 
Hard DriveHard DriveOSMonitor
External 500GB for storage Crucial M4 128GB Windows 7  32* LCD Screen 
KeyboardPowerCase
Logitech G110 CX600 Cooler Master 
  hide details  
Reply
My Computer ...
(11 items)
 
  
CPUMotherboardGraphicsRAM
AMD Phenom ii x4 955 @4ghz M4A88T-M/USB3 ASUS HD6870 DirectCU 4GB ValueRam 
Hard DriveHard DriveOSMonitor
External 500GB for storage Crucial M4 128GB Windows 7  32* LCD Screen 
KeyboardPowerCase
Logitech G110 CX600 Cooler Master 
  hide details  
Reply
post #2 of 3
Thread Starter 
Anyone?
My Computer ...
(11 items)
 
  
CPUMotherboardGraphicsRAM
AMD Phenom ii x4 955 @4ghz M4A88T-M/USB3 ASUS HD6870 DirectCU 4GB ValueRam 
Hard DriveHard DriveOSMonitor
External 500GB for storage Crucial M4 128GB Windows 7  32* LCD Screen 
KeyboardPowerCase
Logitech G110 CX600 Cooler Master 
  hide details  
Reply
My Computer ...
(11 items)
 
  
CPUMotherboardGraphicsRAM
AMD Phenom ii x4 955 @4ghz M4A88T-M/USB3 ASUS HD6870 DirectCU 4GB ValueRam 
Hard DriveHard DriveOSMonitor
External 500GB for storage Crucial M4 128GB Windows 7  32* LCD Screen 
KeyboardPowerCase
Logitech G110 CX600 Cooler Master 
  hide details  
Reply
post #3 of 3
Spotify supports JSON, use that instead of XML. That should fix everything.
https://developer.spotify.com/technologies/web-api/
Death Star
(21 items)
 
Darksaber
(11 items)
 
 
CPUMotherboardGraphicsRAM
Athlon II x2 245 Asus M3A78 Radeon HD6570 1GB Mushkin Silverline 2GB DDR2  
Hard DriveOptical DriveOSMonitor
OCZ Vertex 2 120GB Samsung Blu-Ray Windows 7 Samsung 46" DLP 
PowerCaseOther
Silverstone Strider Essentials 400W Silverstone Milo ML03B Hauppage WinTV 1250 
  hide details  
Reply
Death Star
(21 items)
 
Darksaber
(11 items)
 
 
CPUMotherboardGraphicsRAM
Athlon II x2 245 Asus M3A78 Radeon HD6570 1GB Mushkin Silverline 2GB DDR2  
Hard DriveOptical DriveOSMonitor
OCZ Vertex 2 120GB Samsung Blu-Ray Windows 7 Samsung 46" DLP 
PowerCaseOther
Silverstone Strider Essentials 400W Silverstone Milo ML03B Hauppage WinTV 1250 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming