469,964 Members | 1,729 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,964 developers. It's quick & easy.

searching element of xml file for blocks of text

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?

Oct 6 '08 #1
3 1669
On Oct 6, 12:32*pm, "Andy B" <a_bo...@sbcglobal.netwrote:
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/
Oct 6 '08 #2
Andy B wrote:
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.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Oct 6 '08 #3
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.
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Andy B wrote:
>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.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Oct 7 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by sal achhala | last post: by
reply views Thread by Ben Engbers | last post: by
3 posts views Thread by Ahmad Jalil Qarshi | last post: by
5 posts views Thread by dm3281 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.