473,783 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1818
On Oct 6, 12:32*pm, "Andy B" <a_bo...@sbcglo bal.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*******@yaho o.dewrote in message
news:%2******** ********@TK2MSF TNGP05.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1941
by: sal achhala | last post by:
I'm working with java and XML documents in order to search for keywords in a given element name, eg element name 'author' == "jo blogs". The problem is the XML documents are downloaded (this process is automated) from different websites thus the element names for author may differ! Is their a way of dealing with this, such as perhaps a standard adopted by, say educational websites to agree on element names ? Thanks very much
3
6966
by: abs | last post by:
Hi all. I use such code to clone blocks: element = document.getElementById(IdOfElement) element = element.cloneNode(true) new_element = document.getElementById(IdOfElement).appendChild(element) Anybody knows how to set id for the new element ? I mean the id which I coud use in CSS stylesheet for setting css properties of new element.
0
965
by: Ben Engbers | last post by:
Hi, This is the first time I use SAX in order to translate my XML and I encountered the following problem. I use the following Java-code to produce xml that should be transformed (Based on the xml that is created by the 'createXml()' several underlying xml-files are merged together. The resulting xml seems to be well-formed): When I use the xsl-file, only the root element is transformed, resulting
0
3941
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen. It is almost like it is trying to implement it's own COM interfaces... below is the header, and a link to the dll+code: Zip file with header, example, and DLL:...
17
2017
by: J.S. | last post by:
I have a text file with parameters like the following embedded in the text: @@TextBox1@@, @@TextBox2@@, etc. I know how to read this text file. However, I am trying to figure out how to replace these parameters in the text file with values of the textboxes on my Windows Form called Form1. For example, replace @@TextBox1@@ with value of TextBox1, replace @@TextBox2@@ with value of TextBox2, replace @@ComboBox1@@ with value of...
7
2622
by: pbd22 | last post by:
Hi. I am somewhat new to this and would like some advice. I want to search my xml file using "keyword" search and return results based on "proximity matching" - in other words, since the search string will often not produce a direct match, the results will be based on proximity (50%, 20% 100%, etc). are there any good examples out there on how to do keyword searches on XML data? How should i set up my xml file so
3
2165
by: Ahmad Jalil Qarshi | last post by:
Hi, I have a text file having size about 2 GB. The text file format is like: Numeric valueAlphaNumeric values Numeric valueAlphaNumeric values Numeric valueAlphaNumeric values For example consider following chunk of actual data:
5
11280
by: dm3281 | last post by:
Hello, I have a text report from a mainframe that I need to parse. The report has about a 2580 byte header that contains binary information (garbage for the most part); although there are a couple areas that have ASCII text that I need to extract. At the end of the 2580 bytes, I can read the report like a standard text file. It should have CR/LF at the end of each line. What is the best way for me to read this report using C#. It is...
12
2372
by: Alexnb | last post by:
This is similar to my last post, but a little different. Here is what I would like to do. Lets say I have a text file. The contents look like this, only there is A LOT of the same thing. () A registry mark given by underwriters (as at Lloyd's) to ships in first-class condition. Inferior grades are indicated by A 2 and A 3. () The first three letters of the alphabet, used for the whole alphabet. () In church or chapel style; -- said of...
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.