The other answers cover the 2 most common approaches, Xinclude and XML external entities. Microsoft has a really great writeup on why one should prefer Xinclude, as well as several example implementations. I've quoted the comparison below:
The first question one may ask is "Why use XInclude instead of XML
external entities?" The answer is that XML external entities have a
number of well-known limitations and inconvenient implications, which
effectively prevent them from being a general-purpose inclusion
facility. Specifically:
An XML external entity cannot be a full-blown independent XML document—neither standalone XML declaration nor Doctype declaration is
allowed. That effectively means an XML external entity itself cannot
include other external entities.
An XML external entity must be well formed XML (not so bad at first glance, but imagine you want to include sample C# code into your XML
document).
Failure to load an external entity is a fatal error; any recovery is strictly forbidden.
Only the whole external entity may be included, there is no way to include only a portion of a document.
-External entities must be declared in a DTD or an internal subset. This opens a Pandora's Box full of implications, such as the fact that
the document element must be named in Doctype declaration and that
validating readers may require that the full content model of the
document be defined in DTD among others.
The deficiencies of using XML external entities as an inclusion
mechanism have been known for some time and in fact spawned the
submission of the XML Inclusion Proposal to the W3C in 1999 by
Microsoft and IBM. The proposal defined a processing model and syntax
for a general-purpose XML inclusion facility.
Four years later, version 1.0 of the XML Inclusions, also known as
Xinclude, is a Candidate Recommendation, which means that the W3C
believes that it has been widely reviewed and satisfies the basic
technical problems it set out to solve, but is not yet a full
recommendation.
<book xmlns:xi="http://www.w3.org/2001/XInclude">
<title>The Wit and Wisdom of George W. Bush</title>
<xi:include href="malapropisms.xml"/>
<xi:include href="mispronunciations.xml"/>
<xi:include href="madeupwords.xml"/>
</book>
Mads Hansen's solution is good but to succeed in reading the external file in .NET 4 took some time to figure out using hints in the comments about resolvers, ProhibitDTD and so on.
This is how it's done:
XmlReaderSettings settings = new XmlReaderSettings();
settings.DtdProcessing = DtdProcessing.Parse;
XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials = System.Net.CredentialCache.DefaultCredentials;
settings.XmlResolver = resolver;
var reader = XmlReader.Create("logfile.xml", settings);
XmlDocument doc = new XmlDocument();
doc.Load(reader);
foreach (XmlElement element in doc.SelectNodes("//event"))
{
var ch = element.ChildNodes;
var count = ch.Count;
}