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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. point to a class name with a string from xml

point to a class name with a string from xml

Scheduled Pinned Locked Moved C#
questionxml
3 Posts 3 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.
  • A Offline
    A Offline
    Ariadne
    wrote on last edited by
    #1

    Hi, is there a way to point with a string to a specific class? I want deserialize a XML-Stream into a structure of variables. I tried with Score = (score)serializer.Deserialize(reader); but all members of Score are null. I suppose that the xml-file is not compatible with seriliation. So I want do the deserialisation by my own code. This leeds to the question above: If I read an XML-element, how can I assign the XML-attributes to the approprieate element-class?

    Ariadne

    P E 2 Replies Last reply
    0
    • A Ariadne

      Hi, is there a way to point with a string to a specific class? I want deserialize a XML-Stream into a structure of variables. I tried with Score = (score)serializer.Deserialize(reader); but all members of Score are null. I suppose that the xml-file is not compatible with seriliation. So I want do the deserialisation by my own code. This leeds to the question above: If I read an XML-element, how can I assign the XML-attributes to the approprieate element-class?

      Ariadne

      P Offline
      P Offline
      Phillip M Hoff
      wrote on last edited by
      #2

      You can use the XmlElementAttribute and XmlAttributeAttribute to map specific XML elements and attributes to specific object fields and properties. See also: Introducing XML Serialization[^] -Phil

      1 Reply Last reply
      0
      • A Ariadne

        Hi, is there a way to point with a string to a specific class? I want deserialize a XML-Stream into a structure of variables. I tried with Score = (score)serializer.Deserialize(reader); but all members of Score are null. I suppose that the xml-file is not compatible with seriliation. So I want do the deserialisation by my own code. This leeds to the question above: If I read an XML-element, how can I assign the XML-attributes to the approprieate element-class?

        Ariadne

        E Offline
        E Offline
        Ennis Ray Lynch Jr
        wrote on last edited by
        #3

        Class names are PascalCase and variable names are camelCase: Score score = (Score)serializer.Deserialize(reader);


        On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage

        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