simple XML deserialization question

G

Guest

I have a tiny xml file here that I am trying to deserialize into an object
but get an error
I have tried XMLvalidating reader but that seemed to work fine: Here's the
xml file & the code. What causes this errror ?

Here's the error:
An unhandled exception of type 'System.InvalidOperationException' occurred
in system.xml.dll Additional information: There is an error in XML document
(2, 2).

<?xml version="1.0" encoding="UTF-8"?>
<htbexes name="MainMenu.htb"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="htbpath.xsd">
<HTBPath path="c:\program files\functional test\HTBWin\HTBWin.exe"/>
<HTBPath path="c:\program files\HTBWin\HTBWin.exe"/>
</htbexes>

private string htbpath="htbpath.xml";
public object simpleXMLDeserializer(string fiPath, XmlSerializer serializer)
{
object foo;
TextReader reader = new StreamReader(fiPath);
foo =serializer.Deserialize(reader);
return foo;
}

if (File.Exists(htbpath))
{ // we need the code to open and deserialize the object !
XmlSerializer HTBPathSerializer = new XmlSerializer(typeof(HTBPath));
HTBPath htbPath = new HTBPath();
htbPath = (HTBPath)simpleXMLDeserializer(htbpath,HTBPathSerializer);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top