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. XML / XSL
  4. Serializing XML element with scope in .NET

Serializing XML element with scope in .NET

Scheduled Pinned Locked Moved XML / XSL
csharpxmltutorialquestion
3 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.
  • C Offline
    C Offline
    Chris Maunder
    wrote on last edited by
    #1

    I have a class that contains elements: class MyClass { int var1; string var2; } I'm using the XmlSerializer class to output objects of MyClass to an XML stream and I'm trying to work out how to get the output to be like: ... Value 1 Value 2 ... I've played around with the XmlElementX attributes classes but no luck. The XmlElement.Prefix property seems to be one solution, except that the compiler barfs saying Prefix isn't a member (contradicting the docs and intellisese). Any ideas? cheers, Chris Maunder

    P 1 Reply Last reply
    0
    • C Chris Maunder

      I have a class that contains elements: class MyClass { int var1; string var2; } I'm using the XmlSerializer class to output objects of MyClass to an XML stream and I'm trying to work out how to get the output to be like: ... Value 1 Value 2 ... I've played around with the XmlElementX attributes classes but no luck. The XmlElement.Prefix property seems to be one solution, except that the compiler barfs saying Prefix isn't a member (contradicting the docs and intellisese). Any ideas? cheers, Chris Maunder

      P Offline
      P Offline
      Philip Fitzsimons
      wrote on last edited by
      #2

      chris you need to use XmlSerializerNamespaces http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlserializationxmlserializernamespacesclasstopic.asp[^]


      "When the only tool you have is a hammer, a sore thumb you will have."

      C 1 Reply Last reply
      0
      • P Philip Fitzsimons

        chris you need to use XmlSerializerNamespaces http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlserializationxmlserializernamespacesclasstopic.asp[^]


        "When the only tool you have is a hammer, a sore thumb you will have."

        C Offline
        C Offline
        Chris Maunder
        wrote on last edited by
        #3

        Thanks! cheers, Chris Maunder

        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