A line is rarely a useful concept in an XML document. For example:
<foo>
<bar first="x"
second="y" />
</foo>
is equivalent to
<foo>
<bar first="x" second="y" />
</foo>
Normally you'd query an XML document for individual elements rather than lines. A line would be much more sensible in a .ini file, however.
What's the bigger picture here? What are you trying to achieve?
If you need to read all the lines of a text file (but you don't need them all in memory at once) I'd recommend using File.OpenText
which returns a TextReader
, then calling ReadLine()
and processing the strings as you go until the line returned is Nothing
(which means you've reached the end of the file). Don't forget to wrap the reader in a Using
statement.
EDIT: If you don't need anything else in the file, then I'd just write one entry per line and you're basically done. On the other hand, that means if you ever need any other configuration information, you'll need to change everything.
Using an ini-file would be fairly simple, but you'd have to write the code to parse it. (There may be 3rd party libraries around to do it for you, admittedly. I wrote one at a previous company, and it didn't take very long.)
Using an XML file would introduce a bit more "fluff" around the values, but it would be quite simple to read, particularly if you're using .NET 3.5 and LINQ to XML. For instance, you could have a file like this:
<Configuration>
<RegistryEntries>
<RegistryEntry>First</RegistryEntry>
<RegistryEntry>Second</RegistryEntry>
<RegistryEntry>Third</RegistryEntry>
</RegistryEntries>
</Configuration>
and get the sequence of entries just by doing:
document.Root.Element("RegistryEntries")
.Elements("RegistryEntry")
.Select(e => e.Value);
As yet another alternative, you could use the built-in configuration/settings features of .NET. Have you tried using the "Settings" part of project properties?