473,327 Members | 2,094 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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 2633
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.selectNodes("//ADDRESSINFO[@name='5th
Street']/HOUSE")
or something similar. (Sorry my Xpath is rusty).
Peter

"Steven" <counterball_20122@_hotmail.com> wrote in message
news:uI**************@TK2MSFTNGP14.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*******@yahoo.com> wrote in message
news:ub**************@TK2MSFTNGP09.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.selectNodes("//ADDRESSINFO[@name='5th
Street']/HOUSE")
or something similar. (Sorry my Xpath is rusty).
Peter

"Steven" <counterball_20122@_hotmail.com> wrote in message
news:uI**************@TK2MSFTNGP14.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*******@yahoo.com> wrote in message
news:ub**************@TK2MSFTNGP09.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.selectNodes("//ADDRESSINFO[@name='5th
Street']/HOUSE")
or something similar. (Sorry my Xpath is rusty).
Peter

"Steven" <counterball_20122@_hotmail.com> wrote in message
news:uI**************@TK2MSFTNGP14.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
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...
3
by: Fernando Rodriguez | last post by:
Hi, How can I extract all the strings in an exe with python? O:-)
9
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...
4
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
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...
9
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: "...
3
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 ...
4
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...
1
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...
3
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.