I want to load an XML file that I make by getting data from my database. However, if I want to read that data, it says there"s an error on line 1. Line 1 is strange indeed, because I never asked for "ArrayOfBand". But even when it's there I get all my Bands when i put a break point. It just crashes at the last step. Error HRESULT: 0xC00CE556
XAML on localhost
<ArrayOfBand xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schemas.datacontract.org/2004/07/WindowsStoreApp.Models">
<Band>
<Description>Noorse DJ</Description>
<Facebook>Avicii</Facebook>
<ID>156</ID>
<Name>Avicii</Name>
<Picture>..\Images\Avicii.jpg</Picture>
<Twitter>#Avicii</Twitter>
</Band>
<Band>
<Description>Heavy Metal</Description>
<Facebook>A7X</Facebook>
<ID>157</ID>
<Name>Avenged Sevenfold</Name>
<Picture>..\Images\A7X.jpg</Picture>
<Twitter>#A7X</Twitter>
</Band>
</ArrayOfBand>
C# xml reader
string m_strFilePath = "http://localhost:17281/api/Band";
XmlDocument myXmlDocument = new XmlDocument();
myXmlDocument.Load(m_strFilePath); //Load NOT LoadXml
XmlNodeList elemList = myXmlDocument.GetElementsByTagName("Band");
for (int i = 0; i < elemList.Count; i++)
{
XAML station = new XAML() {
ID = elemList[i].Attributes["ID"].InnerText,
Name = elemList[i].Attributes["Name"].InnerText
};
list.Add(station);
}
return list;
}
c# for creating the xml file
you can see I'm not asking for an "ArrayOfBand". If i take the file and remove "ArrayOfBand" it works perfectly. Anyone has an idea why it's there? public static List GetBands() { List list = new List(); DbDataReader reader = Database.GetData("SELECT * FROM Band");
while (reader.Read())
{
Band b = new Band();
b.ID = reader["ID"].ToString();
b.Name = reader["Name"].ToString();
b.Picture = reader["Picture"].ToString();
b.Description = reader["Description"].ToString();
b.Twitter = reader["Twitter"].ToString();
b.Facebook = reader["Facebook"].ToString();
list.Add(b);
}
return list;
}