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. How to render empty byte array element as xml tag in c#?

How to render empty byte array element as xml tag in c#?

Scheduled Pinned Locked Moved C#
4 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.
  • R Offline
    R Offline
    Raghavendra Kodimala
    wrote on last edited by
    #1

    Hi, I'm using a property as byte array in a model. Now while serializing this model into xml, if this property is null, then it's not rendering as tag. I'm using [XmlElement(IsNullable=true)] attribute on that property.If i do this, in this case it's creating tag with attribute something like xi:nil=true. I don't want this. If that property is null, then make it as empty element else assign value. Please give me solution.

    L 1 Reply Last reply
    0
    • R Raghavendra Kodimala

      Hi, I'm using a property as byte array in a model. Now while serializing this model into xml, if this property is null, then it's not rendering as tag. I'm using [XmlElement(IsNullable=true)] attribute on that property.If i do this, in this case it's creating tag with attribute something like xi:nil=true. I don't want this. If that property is null, then make it as empty element else assign value. Please give me solution.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Why do you care what the XML looks like? Supply a default constructor for the class in question with an initializer for the byte array to resolve any nulls when de-serializing.

      R 1 Reply Last reply
      0
      • L Lost User

        Why do you care what the XML looks like? Supply a default constructor for the class in question with an initializer for the byte array to resolve any nulls when de-serializing.

        R Offline
        R Offline
        Raghavendra Kodimala
        wrote on last edited by
        #3

        The other party app receiving XML without any attributes. If any attributes are there that throwing exception

        L 1 Reply Last reply
        0
        • R Raghavendra Kodimala

          The other party app receiving XML without any attributes. If any attributes are there that throwing exception

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Then use the error handler of the serializer to do a fix-up. Or tell the receiving app to fix their class constructor. You don't like your options? Life is hard and you die.

          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