Search code examples
c#winformsresx

xml:space in resource file of c# winform


I have a windows form application in that i have resource file(.resx)here i write all my error messages like below

 <data name="Link_Name" xml:space="preserve">
    <value>The Link Name must be not blank and not greater than 255 symbols.</value>
  </data>

Here i understood name is the name of the resource which needs to be accessed and the value is the value of the resource But i did not get what is xml:space="preserve" ? i have one more option there default


Solution

  • xml:space="preserve" makes that whitespaces at the begin of the tag is not removed. (And also if you place more than one whitespace together)

    example:

    <data name="Link_Name" xml:space="preserve">
       <value>      The Link Name must be not blank and not greater than 255 symbols.</value>
    </data>
    

    Now the value will be:

    "      The Link Name must be not blank and not greater than 255 symbols."
    

    If xml:space is not set:

    <data name="Link_Name">
       <value>      The Link Name must be not blank and not greater than 255 symbols.</value>
    </data>
    

    The value will be:

    "The Link Name must be not blank and not greater than 255 symbols."
    

    So xml:space="preserve" preserves the whtespaces at begin of the tag.