views:

21

answers:

1

Let's suppose we have an element like this one in the main xml file: <group name="gr1" filename="groups/gr1.xml"/>. The second file gr1.xml contains something like this:

<item name="i1">Item one</item>
<item name="i2">Item two</item>
<item name="i3">Item three</item>

Note that there is no XML declaration in gr1.xml, just plain items without single parent node.

So… Which is the best way to replace <group/> with its <item/>s?

I have already tried some things like manual enclosing of gr1.xml content into a single node with XML declaration and loading it into XmlDocument, but it doesn't look like a good solution.

A: 

You could use a DTD and external entity. You would need to explicitly enable DTD processing when loading the outer file.

Otherwise you can load a document fragment, and add its nodes yourself.

Richard
It's actually much easier. I've just figured out :)
Entrase
No. It was a mistake :(
Entrase