Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Deseralize an array of objects

Deseralize an array of objects

Scheduled Pinned Locked Moved C#
questiondata-structurestestingbeta-testingannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eggie5
    wrote on last edited by
    #1

    How can I have XmlSerializer.Deserializer deserialize an array of Category objects? Right now it'll only work on a single Category object. − 1 2 Traffic Alerts − 1 1 News Alerts − 1 3 testing category − 1 7 curl test − 1 8 sapce test

    T 1 Reply Last reply
    0
    • E eggie5

      How can I have XmlSerializer.Deserializer deserialize an array of Category objects? Right now it'll only work on a single Category object. − 1 2 Traffic Alerts − 1 1 News Alerts − 1 3 testing category − 1 7 curl test − 1 8 sapce test

      T Offline
      T Offline
      TJoe
      wrote on last edited by
      #2

      Assuming that "categories" is your root XML element, then you can do the following:

      using System;
      using System.Collections.Generic;
      using System.Xml.Serialization;

      namespace WindowsApplication1 {
      [XmlRoot("categories")]
      public class categories : List<category> {
      }
      }

      When building your XmlSerializer, you need to specify "categories" as the type like so:

      XmlSerializer xs = new XmlSerializer(typeof(categories));

      -- modified at 11:59 Monday 1st October, 2007 -- Had to escape out <

      Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups