I’m newly back into programming after a 25 year diversion, and I’m brand-new to embedded processors; Yikes! I’m using a Fez Cobra and trying to use XmlReader to read from an RSS website. I suspect that my problem has more to do with the network setup than the XmlReader. My sample code including output is below. Any help that you can give me would be greatly appriciated. Thank you, Carl
using System;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Xml;
using System.IO;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
namespace FEZ_Cobra_Console_Application1
{
public class Program
{
public static void Main()
{
// PROGRAM INTENDED TO RUN ON FEZ COBRA
if (Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces().Length < 1)
{
Debug.Print("No Active network interfaces. Bombing out.");
Thread.CurrentThread.Abort();
}
Microsoft.SPOT.Net.NetworkInformation.NetworkInterface NI = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0];
if (NI.IsDhcpEnabled == false)
{
Debug.Print("Enabling DHCP.");
NI.EnableDhcp();
Debug.Print("DCHP - IP Address = " + NI.IPAddress + " ... Net Mask = " + NI.SubnetMask + " ... Gateway = " + NI.GatewayAddress);
}
else
{
Debug.Print("Renewing DHCP lease.");
NI.RenewDhcpLease();
Debug.Print("DCHP - IP Address = " + NI.IPAddress + " ... Net Mask = " + NI.SubnetMask + " ... Gateway = " + NI.GatewayAddress);
}
XmlReader xmlDoc;
try
{
WebRequest aRequest = WebRequest.Create("http://rss.cnn.com/rss/cnn_us.rssurlStr");
WebResponse aResponse = aRequest.GetResponse();
xmlDoc = XmlReader.Create(aResponse.GetResponseStream());
Debug.Print("About to do XML Read");
do
{
xmlDoc.Read();
Debug.Print(xmlDoc.Name);
}
while (!xmlDoc.EOF);
Debug.Print("XML Read completed");
xmlDoc.Close();
}
catch
{
Debug.Print("Error doing Xml Read");
}
}
}
}
FEZ COBRA OUTPUT IS AS FOLLOWS:
Renewing DHCP lease.
DCHP - IP Address = 10.0.0.25 ... Net Mask = 255.0.0.0 ... Gateway = 10.0.0.60
About to do XML Read
#### Exception System.Xml.XmlException - 0xdd000000 (1) ####
#### Message:
#### System.Xml.XmlReader::Read [IP: 00d1] ####
#### FEZ_Cobra_Console_Application1.Program::Main [IP: 00e8] ####
A first chance exception of type 'System.Xml.XmlException' occurred in System.Xml.dll
Error doing Xml Read
The thread '<No Name>' (0x1) has exited with code 0 (0x0).
Done.