Please see my comment to the question — it's not clear. You know what? Read on the different ways of XML parsing, learn how to do it and deal with the rest on your own, as you cannot explain it clearly.
So, here are your options:
- Use
System.Xml.XmlDocument
class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^]. - Use the class
System.Xml.XmlTextReader
; this is the fastest way of reading, especially is you need to skip some data.
See http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^]. - Use the class
System.Xml.Linq.XDocument
; this is the most adequate way similar to that of XmlDocument
, supporting LINQ to XML Programming.
See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].
Have fun!
[EDIT]
After explanation: in this simple case, the most effective method would be
System.Xml.XmlTextReader
. It allows you to read forward-only. Look at this example:
http://msdn.microsoft.com/en-us/library/system.xml.xmltextreader.read.aspx[
^]. This is what you need to do: read it all to the end; on the road, pick up the types of nodes you need. In your example this must be
XmlNodeType.Text
. Take it text and search your pattern in it. Add results to the instance of
System.Collections.Generic.List<System.String>
in case of every match. At the end you will have a list of matches. Problem solved.
—SA