Deserialize XML files in Web Build

I use the following code to deserialize an XML file:

Stream stream = new MemoryStream();
var xmlSerializer = new XmlSerializer(typeof(ItemDirectory));

if(Application.platform == RuntimePlatform.WindowsWebPlayer ) {
    TextAsset text = Resources.Load("Items.xml") as TextAsset;
	stream = new MemoryStream(text.bytes);//throws NullReference error
}
else {
	string path = "C:/Items.xml";
	stream = File.Open(path, FileMode.Open);
}

		
var deserializedItems = xmlSerializer.Deserialize(stream) as ItemDirectory;
stream.Close();
//Do stuff with the deserializedItems

The SML deserialization works flawless in a standalong build, but in a webplayer build, this line throws a NullReferenceError:

stream = new MemoryStream(text.bytes);

I know I need a Stream for the xmlSerializer.Deserialize method, and it’s not problem with File.Open, but for the Webplayer build, I have to include the xml file in the Resources folder and use Resources.Load, but I don’t know how to get the stream from it.

The filename argument to Resources.Load must not contain the file extension. So it should be:

     TextAsset text = Resources.Load("Items") as TextAsset;