I’m using .NET C# XML and LINQ to Update/delete/insert my XML file.
I’ve got an XML file looks like below (image1) and I would like to inlcude just the 2nd XML file.
The first XML file is the original file and I don’t want to touch this file. So I prefer a reference to a 2nd. file (external file) so I can add/remove XML lines there in stead of the Mainf XML file.
But how can do include or merge the 2nd XML (External file) in to the FIRST?
I just need to the tags (see RED box) from see in RED box.
<RewriterRule>
<LookFor> </LookFor>
<SendTo> </SendTo>
</RewriterRule>
Question:
1- What do I need to write for code in XML file 1 so my code in XMLfile 2 (external file) is included?
2- How should my XMLfile 2 (external file) look like? In fact I need the tags I think, because I’m reading the XML XDocument xdoc = XDocument.Load(this.Server.MapPath(path));and doing some update/deletes…..

IMAG2 – EXTERNAL FILE

Well adding elements from a second file is easy:
On the other hand the term “merging” suggests you might want to do something more complex like identifying elements based on some id or key and then not simply add new elements but overwrite some data. You will need to provide more details on exactly what kind of merge process you want if you need help with writing the code.
[edit] Here is an example on how to use the DTD based mechanism of a reference to an external entity to include an XML fragment file into another document: file1.xml is as follows:
fragment.xml is as follows:
Then, when reading in the main file with LINQ to XML and .NET 4.0 you need to make sure the XmlReader you use is set to parse the DTD e.g.