I have quite complicated XML strings coming from somewhere else and I need to parse it in C#.
Because of the complexity of XML, I decided to use XmlSerializer after getting an xsd file. But my xml code never seem to work..

here is my myxml.xml:

<?xml version="1.0" encoding="iso-8859-1"?>
  <category name="Cards" id="38">
    <subcategory name="4x6_Anniversary" id="Anniversary_4x6" product_schema="4x6_card">
      <border id="4x6_anniversary_brownie_l.tif" name="4x6 Anniversary Brownie L" orientation="landscape" width="1800" height="1200" filename="4x6_anniversary_brownie_l.png" transparent_color="ffffff">
        <inner_window x="203" y="101" width="671" height="1025" />
        <thumb filename="4x6_anniversary_brownie_l_thumb.png" width="180" height="120" />
        <medium_thumb filename="4x6_anniversary_brownie_l_med_thumb.png" width="480" height="320" />
          <text x="1015" y="671" width="651" height="369" name="">
            <property name="max_characters">1000</property>
            <property name="min_characters">0</property>
            <property name="font_color">ffffffff</property>
            <property name="font_face">Arial</property>
            <property name="required">false</property>
            <property name="font_size">30</property>
            <property name="bold">false</property>
            <property name="italic">false</property>
            <property name="default_text">Some texts.</property>

I created myxml.xsd and myxml.cs, and put them in my solution

Next, here's my XML parsing code in C#:

Stream stream = File.OpenWrite(filePath);
XmlSerializer xs = new XmlSerializer(typeof(cm_borders));

But I keep getting an error which says

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Xml.dll

Additional information: Unable to generate a temporary class (result=1).

error CS0030: Cannot convert type 'XMLFormatConvertor.xsd.sf_bordersCategorySubcategoryBorderText_listText[]' to 'XMLFormatConvertor.xsd.sf_bordersCategorySubcategoryBorderText_listText'

What should I do to fix this?
If you know any good C# XML deserialize/serialize libraries, please let me know..

I found a work around. I just removed <text_list> and </text_list>, and it works :S

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.