How to embed inline XML/HTML in a Resx file? RRS feed

  • Question

  • User-1068772371 posted
    I would like to place XML and/or HTML tags inside an XML Resource (*.resx) file. This is easy to do within text based resource files; likewise, I would assume that resx files (being XML based) would support the standard CData tag. However, when putting a CData tag in a Resx file, I receive a parsing error during the compilation process (reporting that the CDATA field is not closed). Conversely, if I just include HTML inline then the ResourceManager object returns the innertext of the first element as the value. Examples: This returns an error when running ResGen: <data Name="ResourceName"> <value><![CDATA[Hello World]]</value> </data> This outputs "Hello" (without the bold tags or "world": <data Name="ResourceName"> <value>Hello World</value> </data> I haven't researched this extensively, although I did run a couple of obvious trials and do a due dilligence scan of popular internet resources. I found a few pages in Japanese referencing similar markup although the translations provided by google didn't provide me with a coherent solution. Thoughts?
    Tuesday, February 1, 2005 12:37 PM

All replies

  • User-1068772371 posted
    The solution is to encode the HTML (which the XML tools in .NET will automatically do for you if you're accessing the resource file via the DOM). e.g., <data Name="ResourceName"> <value><b>Hello</b> World</value> </data>
    Tuesday, February 1, 2005 2:34 PM
  • User1305495489 posted
    encoding html is just boring i am using CDATA and it works
    Wednesday, March 16, 2005 2:57 AM