473,836 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extract Strings

Following is the string ...

<ADDRESSINFO name = "Cedar Ave" no = "21123" attrib ="visible">
<HOUSE name ="main" type ="1" value ="2200"/>
<HOUSE name ="slide" type ="12" value ="123"/>
<HOUSE name ="major" type ="1" value ="1234"/>
<HOUSE name ="branch" type ="1" value ="31980"/>
</ADDRESSINFO>

<ADDRESSINFO name = "5th Street" no = "65653" attrib ="visible">
<HOUSE name ="minor" type ="2" value ="43121"/>
<HOUSE name ="corner" type ="90" value ="65109"/>
<HOUSE name ="tree" type ="22" value ="7"/>
<HOUSE name ="walk" type ="2" value ="721"/>
</ADDRESSINFO>

............... ............... ............... ........
............... ............... ............... .......// text goes on like this
I want to give the name value in ADDRESSINFO tag and get all the House names
of that particular Addressin an array. How can I do this?

eg., If I give 5th street as the input, I should get minor, corner, tree,
walk in an array .

Any help would be greatly appreciated!

Regards
Steven
Nov 16 '05 #1
3 2665
Ok, well this isn't an ordinary string, its the string representation of an
Xml Document.
So you would load this into a new XmlDocument
instance
and use Xpath query methods

XmlNodelist nodList1 = xmlDoc.selectNo des("//ADDRESSINFO[@name='5th
Street']/HOUSE")
or something similar. (Sorry my Xpath is rusty).
Peter

"Steven" <counterball_20 122@_hotmail.co m> wrote in message
news:uI******** ******@TK2MSFTN GP14.phx.gbl...
Following is the string ...

<ADDRESSINFO name = "Cedar Ave" no = "21123" attrib ="visible">
<HOUSE name ="main" type ="1" value ="2200"/>
<HOUSE name ="slide" type ="12" value ="123"/>
<HOUSE name ="major" type ="1" value ="1234"/>
<HOUSE name ="branch" type ="1" value ="31980"/>
</ADDRESSINFO>

<ADDRESSINFO name = "5th Street" no = "65653" attrib ="visible">
<HOUSE name ="minor" type ="2" value ="43121"/>
<HOUSE name ="corner" type ="90" value ="65109"/>
<HOUSE name ="tree" type ="22" value ="7"/>
<HOUSE name ="walk" type ="2" value ="721"/>
</ADDRESSINFO>

............... ............... ............... .......
............... ............... ............... ......// text goes on like
this
I want to give the name value in ADDRESSINFO tag and get all the House
names of that particular Addressin an array. How can I do this?

eg., If I give 5th street as the input, I should get minor, corner, tree,
walk in an array .

Any help would be greatly appreciated!

Regards
Steven

Nov 16 '05 #2
Keep in mind it's not well-formed XML (needs a root node), but assuming this
is only a partial XML file and there is a root node, after you perform your
XPath query on it, you can iterate the nodes like this:

foreach XmlNode xn in nodList1
{
// Use the Attributes[ ] property of xn to access the name,
// type and value attributes in your XML Nodes
}

"Peter Bromberg [MVP]" <pb*******@yaho o.com> wrote in message
news:ub******** ******@TK2MSFTN GP09.phx.gbl...
Ok, well this isn't an ordinary string, its the string representation of
an Xml Document.
So you would load this into a new XmlDocument
instance
and use Xpath query methods

XmlNodelist nodList1 = xmlDoc.selectNo des("//ADDRESSINFO[@name='5th
Street']/HOUSE")
or something similar. (Sorry my Xpath is rusty).
Peter

"Steven" <counterball_20 122@_hotmail.co m> wrote in message
news:uI******** ******@TK2MSFTN GP14.phx.gbl...
Following is the string ...

<ADDRESSINFO name = "Cedar Ave" no = "21123" attrib ="visible">
<HOUSE name ="main" type ="1" value ="2200"/>
<HOUSE name ="slide" type ="12" value ="123"/>
<HOUSE name ="major" type ="1" value ="1234"/>
<HOUSE name ="branch" type ="1" value ="31980"/>
</ADDRESSINFO>

<ADDRESSINFO name = "5th Street" no = "65653" attrib ="visible">
<HOUSE name ="minor" type ="2" value ="43121"/>
<HOUSE name ="corner" type ="90" value ="65109"/>
<HOUSE name ="tree" type ="22" value ="7"/>
<HOUSE name ="walk" type ="2" value ="721"/>
</ADDRESSINFO>

............... ............... ............... .......
............... ............... ............... ......// text goes on like
this
I want to give the name value in ADDRESSINFO tag and get all the House
names of that particular Addressin an array. How can I do this?

eg., If I give 5th street as the input, I should get minor, corner, tree,
walk in an array .

Any help would be greatly appreciated!

Regards
Steven


Nov 16 '05 #3
oops, forgot parens (too much darn VB programming at work):

foreach (XmlNode xn in nodList1)
{
// Use the Attributes[ ] property of xn to access the name,
// type and value attributes in your XML Nodes
}

"Peter Bromberg [MVP]" <pb*******@yaho o.com> wrote in message
news:ub******** ******@TK2MSFTN GP09.phx.gbl...
Ok, well this isn't an ordinary string, its the string representation of
an Xml Document.
So you would load this into a new XmlDocument
instance
and use Xpath query methods

XmlNodelist nodList1 = xmlDoc.selectNo des("//ADDRESSINFO[@name='5th
Street']/HOUSE")
or something similar. (Sorry my Xpath is rusty).
Peter

"Steven" <counterball_20 122@_hotmail.co m> wrote in message
news:uI******** ******@TK2MSFTN GP14.phx.gbl...
Following is the string ...

<ADDRESSINFO name = "Cedar Ave" no = "21123" attrib ="visible">
<HOUSE name ="main" type ="1" value ="2200"/>
<HOUSE name ="slide" type ="12" value ="123"/>
<HOUSE name ="major" type ="1" value ="1234"/>
<HOUSE name ="branch" type ="1" value ="31980"/>
</ADDRESSINFO>

<ADDRESSINFO name = "5th Street" no = "65653" attrib ="visible">
<HOUSE name ="minor" type ="2" value ="43121"/>
<HOUSE name ="corner" type ="90" value ="65109"/>
<HOUSE name ="tree" type ="22" value ="7"/>
<HOUSE name ="walk" type ="2" value ="721"/>
</ADDRESSINFO>

............... ............... ............... .......
............... ............... ............... ......// text goes on like
this
I want to give the name value in ADDRESSINFO tag and get all the House
names of that particular Addressin an array. How can I do this?

eg., If I give 5th street as the input, I should get minor, corner, tree,
walk in an array .

Any help would be greatly appreciated!

Regards
Steven


Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2064
by: Logical | last post by:
I wanted to do: include('page.htm?id=12&foo=bar'); But since I can't (and don't want to make another seperate HTTP request with include('http://...')); I was wondering if there's a function similar to extract(); that can handle a query string as input, so that I could: $id = 12; $foo = 'bar'; include('page.htm');
3
5115
by: Fernando Rodriguez | last post by:
Hi, How can I extract all the strings in an exe with python? O:-)
9
16992
by: Sharon | last post by:
hi, I want to extract a string from a file, if the file is like this: 1 This is the string 2 3 4 how could I extract the string, starting from the 10th position (i.e. "T") and extract 35 characters (including "T") from a file and then go to next line?
4
2127
by: Barry | last post by:
How can I open a word doc and extract the text as text without any formatting characters?? -- Barry Fitzgerald
4
2879
by: yinglcs | last post by:
Hi, how can I extract 2 integers from a string in python? for example, my source string is this: Total size: 173233 (371587) I want to extract the integer 173233 and 371587 from that soource string, how can I do that?
9
9469
by: flit | last post by:
Hello All, Using poplib in python I can extract only the headers using the .top, there is a way to extract only the message text without the headers? like remove the fields below: " Return-Path: X-Original-To: Received: from
3
5733
by: maylee21 | last post by:
hi, anyone can help me figure out how to read data from a text file like this: 10980012907200228082002 and extract the data according to this kind of format: Record type 1 TY-RECORD PIC (1). ID-PARTICIPANT PIC (6).
4
2636
by: Horacius ReX | last post by:
Hi, I have to read some data from a file, and on each block it always appears the followng string; xyz.vs.1-81_1 . It appears a lot of time with different numbers like; xyz.vs.1-81_1 xyz.vs.1-1234_1 xyz.vs.1-56431_1
1
2040
by: davidson1 | last post by:
Hai, i have a string 04AF045 in that AF are character , others are numbers , now what i need is i have to extract AF alone in ASP.NET written in vb. if anybody know pl reply me.. other example 05AD100
3
10602
by: SteveB | last post by:
I have posted this question in the Visual Basic 2005 and Visual Basic .Net 2005 discussion groups, also. Hi. I am developing an application/web page with VB.Net that will populate a SQL database from text extracted from PDF documents. However, I am having a difficult time finding or developing the appropriate code to convert the PDF streams into text strings. Has anyone developed code to convert PDF's to Text? I was able write a...
0
9818
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
10844
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...
1
10590
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10254
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...
0
9374
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7791
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
5649
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4449
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.