How to embed multiple Xml fragments in a single resource file in C# 2005?

Hi,

My application needs to work with several small Xml fragments. I want to type them verbatim, but the problem with using verbatim string literals is that I need to escape the actual quote inside Xml with another quote for compiler to understand.

On the other hand, if I want to use Xml as a resource, then for each of the several Xml fragments, I need to create a separate resource file. Ideally what I want is a mechanism where:

1. I can store all the Xml fragments in a single file, with separate name or identifier for each Xml fragment, and
2. I can type the Xml as it is without escaping quotes and I can type them in multi line with indenting for easier readability

Is there any mechanism it can be achieved?

 




allsolutionsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jacques Bourgeois (James Burger)PresidentCommented:
It is not evident at first sight, but you can have many lines in the same resource entry. There are 3 ways to do that.

You can press Shift-Enter in the resource editor to generate a line feed, and display many lines by heightening the row, just as you would do in Excel or most grids. However, I have not found a way of generating tabulations in the editor.

You can type you Xml fragment in any text editor, and then copy an paste into the resource editor. Both tabs and line feeds are kept this way.

The third way requires a little more attention on your part: edit the resource.resx file manually. You do not see it by default, but if you activate the Show All Files button at the top of the Solution Explorer, you will find the generated resource file under My Project.
0
allsolutionsAuthor Commented:
I can see Resource.resx file. If I double click, it opens the Resource Editor. Below it is the generated file: Resources.Designer.cs. In which section in this generated file should I put my Xml fragments? Since it is auto generated, will it retain the changes, if I open the editor and type some value directly in editor?
0
Jacques Bourgeois (James Burger)PresidentCommented:
First copy and each chunck as an entry in the resource editor:
 Resource editorIf you put the cursor in the entry, you will see the tabulations:
 
You can edit from there. There is no shortcut to enter a new tabulation, but you can select one and copy and paste if you want to edit from there.
Resource editor in Edit modeIf you prefer, do a save from the resource editor and then open the .resx file in the XML Editor by right clicking on it and going Open With. Then find the entry that has been generated from the resource editor and edit it to your taste:
 XML editorThe .vb file is a class generated by the resource editor that is compiled into the application. This is the class you use later in your application to retrieve the resources. I would not touch that one.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.