I have several XML files that I wish to read attributes from. My main objective is to apply syntax highlighting to rich text box.
For example in one of my XML docs I have: <Keyword name="using">[..] All the files have the same element: Keyword.
So, how can I get the value for the attribute name and put them in a collection of strings for each XML file.
I am using Visual C# 2008.
The other answers will do the job – but the syntax highlighting thingy and the several xml files you say you have makes me thinks you need something faster, why not use a lean and mean
XmlReader?Another good option would be the
XPathNavigatorclass – which is faster than XmlDoc and you can use XPath.Also I would suggest to go with this approach only IFF after you try with the straightforward options you’re not happy with performance.