XML Deseriazlier exception C# -


i'm using c# (wpf).
have following xml file:

<?xml version="1.0" encoding="utf-8"?> <applicationtorun isfromxml="true"> <apps>     <fulllpath>c:\file1.txt</fullpath>     <fulllpath>c:\file2.txt</fullpath>     <fulllpath>c:\file3.txt</fullpath> </apps> 

</applicationtorun> 

and try deseriazlier xml file.
my code:

mlserializer xs = new xmlserializer(typfof(myxmlclass)); stringreader st = new stringreader(xmlpath);  myxmlclass apps = (myxmlclass)xs.deserialize(st); //exception - system.windows.markup.xamlparseexception 


inside inner exception: system.invalidoperationexception :there error in xml document (1.1) ...

classes:

[xmlrootattriute("applicationtorun:) public class myxmlclass {     [xmlattribute]     public bool isfromxml {get;set;}     [xmlelement("apps")]     public fullpath [] fullpath {get;set;} }  public class fullpath {     public stirng fullpathapp {set;get;} } 

where mistake?
thanks!

the xml badly formed, takes bit of cleaning up:

<?xml version="1.0" encoding="utf-8"?> <applicationtorun isfromxml="true">     <apps>         <fullpath>foo</fullpath>         <fullpath>bar</fullpath>     </apps> </applicationtorun> 

then assign correct xml attributes class:

[xmlrootattribute("applicationtorun")] public class myxmlclass {     [xmlattribute]     public bool isfromxml { get; set; }     [xmlarray("apps")]     [xmlarrayitem("fullpath")]     public string[] fullpath { get; set; } } 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -