Evening all,
I've got a requirement to build a small windows forms application in
C# that will filter a specified XML file and save the results in a new
file.
I think I can cope with the basics of loading the source file and
probably saving the results but I'd appreciate a few pointers on the
best way to achieve the filtering of the source XML document.
The document has no DTD or Schema associated with it. For the sake of
this post, it's in the following format:
<root node>
<info>
<elementa>a</elementa>
<elementb>b</elementb>
<elementc>c</elementc>
<elementd>d</elementd>
</info>
<info>
<elementa>e</elementa>
<elementb>f</elementb>
<elementc>g</elementc>
<elementd>h</elementd>
</info>
...
...
</root note>
The desired result is a new file with the same root element and only
one <info> group. The required info group is identified by the value
of one of its elements (it's the same element each time).
It's probably safe to assume that I'll be running this in a .NET2.0
environment so I can't use any of the features of .NET 3 or 3.5.
I'm envisaging a solution whereby I load the XML into a suitable
object and run some kind of XPATH/XQUERY statement on it. Seems like
an elegant solution anyway. I'm happy for you to prove me wrong.
This app is to save users editing raw XML (with no line feeds or white
space) in notepad!
I'm not massively familiar with the intricacies of XML or the
facilities available in .NET to process it so please bear with me if I
ask any daft follow up questions.
Many thanks in advance,
Dave.