Hi,
I really need you guys' help with getting string within string. I have an address validation code that will send a request string to UPS, and if the address is validated, UPS will send a response string back. The problem starts here. Once I get the response string, I want to be able to display only city, state and zipcodes, but I don't know how to grab those values from the response string. The response string looks like this: - <?xml version="1.0"?>
-
<AddressValidationResponse>
-
<Response>
-
<TransactionReference>
-
<CustomerContext>Customer Data</CustomerContext>
-
<XpciVersion>1.0001</XpciVersion></TransactionReference>
-
<ResponseStatusCode>1</ResponseStatusCode>
-
<ResponseStatusDescription>Success</ResponseStatusDescription></Response>
-
<AddressValidationResult>
-
<Rank>1</Rank>
-
<Quality>0.9254</Quality>
-
<Address>
-
<City>MADISON</City>
-
<StateProvinceCode>WI</StateProvinceCode></Address>
-
<PostalCodeLowEnd>53701</PostalCodeLowEnd>
-
<PostalCodeHighEnd>53708</PostalCodeHighEnd></AddressValidationResult></AddressValidationResponse>
So, the only values I want to display are (for example)Madison, WI, 53702, 53708.
Thanks
aboon
8 2152 @vekipeki
Hi, Thanks for the link..I still couldn't get it to work because the XmlReader get text from a file, but the response string I got from UPS does not store in a file. I'm not sure how to just read a string within that string. I tried using SubString, but that didn't work either because the the length of the response string is not consistent. It depends on the values that user type in, and the result of the validation.
please help,
thanks
I've never used XML before (shock) and yet I can see there are 12 overrides for the .Create method - several of them use a System.IO.Stream as the source. So you are not limited to just reading XML files from hard disc.
I would think you can take your incoming data, turn it into a stream if it isn't already, and then feed it to the .Reader object. TIP:
If you aren't accustomed to it, use the tools that Visual Studio gives you, such as the Intellisense.
As you start typing 'XMLReader.' as soon as you hit the period a list of available methods and properties comes up. Type 'Create(', then as soon as you type the left parenthises ( a list of all the overides comes up showing you all the various ways you can call this method with different combinations of arguments. You can hit the up/down arrow keys or click on the up/down arrows of the hothelp that just popped up to see the different overrides.
I'm not sure how to do it exactly..
This is part of the code.after I got user input(city, state, zip), send the request string to UPS to validate the address.
UPSOnlineInterface.Components.Address addr = new UPSOnlineInterface.Components.Address();
addr.City = this.txtCity.Text.Trim();
addr.StateProvinceCode = this.ddlState.SelectedValue;
addr.PostalCode = this.txtZip.Text.Trim();
string response = reques.AddressValidateRequest(accReq, addr);
string encodedString = HttpUtility.HtmlEncode(response).Replace("<", "<BR><").Replace("<BR></", "</");
The "encodingString" is the result of the response string which looks like the top post..the next step is to get the values, and dispay them which I still couldn't figure out.
thanks
there are 12 overrides for the .Create method
As tlhintoq said, using Intellisense can help you find the override that works for you - using the up/down keys you will browse through different tooltips for that method.
Note the Intellisense tooltip in the figure below:
In this case, your method accepts a TextReader, so it means you can create a StringReader from your string and pass it to your method (because StringReader is a concrete implementation of abstract TextReader class).
In this case, your method accepts a TextReader, so it means you can create a StringReader from your string and pass it to your method (because StringReader is a concrete implementation of abstract TextReader class).
Hello,
Thanks you very much for the example. I tried using StringReader and get the innerXml as a result. - XmlDocument xmlDoc = new XmlDocument();
-
xmlDoc.Load(new StringReader(response));
-
XmlNode elem = xmlDoc.DocumentElement;
The innerXml looks something like this:
Customer Data1.00011Success10.9169
MADISONWI
535625356220.9169
MADISONWI
535935359330.9169
MADISONWI
537015370840.9169
MADISONWI
537115371150.9169
MADISONWI
Now, I would like to add the innerXml result into a dropdownlist. Is there a way to do this???
Thank you very much for all your help.
aboon
-
ComboBox bob = new ComboBox();// Or use an existing control
-
string MyNewItem = MyXMLcalculationMethod();// Your method that parses the XML and returns a string to be added to the ComboBox
-
bob.Items.Add(MyNewItem);
-
thank you very much for all your help
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Igor2004 |
last post by:
Ladies and Gentlemen,
I would like to offer you the following string functions Transact-SQL
GETWORDCOUNT() Counts the words in a string
GETWORDNUM() Returns a specified word from a string...
|
by: Igor Nikiforov |
last post by:
Ladies and Gentlemen,
I would like to offer you the following string functions Transact-SQL
GETWORDCOUNT() Counts the words in a string
GETWORDNUM() Returns a specified word from a string...
|
by: Eric Theil |
last post by:
I'm at my wit's end with this one. Within an xsl:if test, I'm not able to
get 2 variables to properly evaluate if one of them is wrapped within a
string function.
<!-- This works -->
<xsl:if...
|
by: Ralph Noble |
last post by:
Does anyone know of a string function in Access that will allow me to
count the number of instances one string occurs within another? Or if
there is some sort of word count function? If there is,...
|
by: Walter Dnes (delete the 'z' to get my real address |
last post by:
I took a C course some time ago, but I'm only now beginning to use it,
for a personal pet project. My current stumbling-block is finding an
efficient way to find a match between the beginning of a...
|
by: tshad |
last post by:
Can you do a search for more that one string in another string?
Something like:
someString.IndexOf("something1","something2","something3",0)
or would you have to do something like:
if...
|
by: Mark |
last post by:
OK. Here we go. I have an ASP.NET application that does many hits to a SQL Server DB on a separate server. When I first created this application (2 years ago) and was very new to ASP/ASP.NET, to...
|
by: pmelanso |
last post by:
Hello,
I am trying to create a method that will see if one string contains a
different string:
This is what I have so far:
Private Function containString(ByVal string1 As String, ByVal...
|
by: comp.lang.tcl |
last post by:
I have a TCL proc that needs to convert what might be a list into a
string to read
consider this:
]; # OUTPUTS Hello World which
is fine for PHP
]; # OUTPUT {{-Hello}}
World, which PHP...
|
by: ReeceSeeSharp |
last post by:
Having difficulty trying to get this code in .NET (C#) to print out this string EXACTLY as it prints out within Java using a) the MD5 hashing algorithm and B). In Java here's how a string "ididnot"...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
|
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...
|
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...
| |