Problem loading an online XML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Cainnech
    New Member
    • Nov 2007
    • 132

    Problem loading an online XML

    Hello everybody,

    I'm encountering some issues while trying to load online XML-content. For some reason I can't select the nodes in the XML-document. Eventhough, if I try it with another source, it's working.

    First of all, here is the structure of the XML:
    Code:
    <?xml>
        <onair>
            <channelCode>55</channelCode>
            <startDate>2013-11-12T21:27:21.000Z</startDate>
            <endDate>2013-11-12T21:30:54.000Z</endDate>
            <type>SONG</type>
            <onairType>PREVIOUS</onairType>
            <properties>
            	<property>
            		<key>ARTISTNAME</key>
            		<value>LIONEL RICHIE</value>
            	</property>
            	<property>
            		<key>TITLE</key>
            		<value>HELLO</value>
            	</property>
            </properties>
        </onair>
        <onair>
            <channelCode>55</channelCode>
            <startDate>2013-11-12T21:30:53.000Z</startDate>
            <endDate>2013-11-12T21:34:23.000Z</endDate>
            <type>SONG</type>
            <onairType>NOW</onairType>
            <properties>
            	<property>
            		<key>ARTISTNAME</key>
            		<value>TRIXIE WHITLEY</value>
            	</property>
            	<property>
            		<key>TITLE</key>
            		<value>NEED YOUR LOVE </value>
            	</property>
            </properties>
        </onair>
    </onairs>
    And this is the code which I'm using:
    Code:
    string urlXML = "http://services.vrt.be/playlist/onair?channel_code=55&accept=application%2Fvnd.playlist.vrt.be.noa_1.0%2Bxml";
    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.Load(urlXML);
    
    XmlNode titleNode = XmlDoc.SelectSingleNode("//onairs/onair/channelCode");
    
    MessageBox.Show(titleNode.InnerText);
    The ultimate goal is to be able to extract the previous and current song information. However, in order to test my code I'm just trying to extract the value of the channelCode.

    But for now I keep on running into "Object reference not set to an instance of an object"

    Anyone sees what's going wrong?

    best regards,
    Kenneth
Working...