searching element of xml file for blocks of text

  • Thread starter Thread starter Andy B
  • Start date Start date
A

Andy B

I need to search an xml element for blocks of text. The start of the text
block will have a 5 digit number in it and i then need to read until the
next 5 digit number. After this, I need to put them in different containers
of their own. Where would I start?
 
I need to search an xml element for blocks of text. The start of the text
block will have a 5 digit number in it and i then need to read until the
next 5 digit number. After this, I need to put them in different containers
of their own. Where would I start?

Look up the following (with regards to .NET) on MSDN, after you learn
a bit you should be able to do what you need.

Xml
XPath
Regex

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
 
Andy said:
I need to search an xml element for blocks of text. The start of the text
block will have a 5 digit number in it and i then need to read until the
next 5 digit number. After this, I need to put them in different containers
of their own. Where would I start?

To find the text contents of the XML element itself you can use
XmlReader or XPathDocument/XPathNavigator or XmlDocument or (with .NET
3.5) LINQ to XML. Then to parse that block of text it sounds as if
regular expressions could help e.g.
\d{5}.*?\d{5}
is a regular expression matching five digits, anything else and five digits.
If you want to manipulate the XML (not sure whether "put them in
different containers" relates to XML) then XmlDocument or LINQ to XML
are the right APIs.
 
Putting it in containers means that I need to get the text blocks. When I
find them I need to put part of it in a textbox and part of it in a
listview/listbox. Here is an example of the text blocks I need to parse.

'following line goes inside a listbox/listview
99999 A description of the item in question

'following steps go inside a textbox
1. step 1
2. step 2
3. step 3

and the steps list continues until another 5 digit number is found. This is
the parsing detail that I need for right now.
 
Back
Top