Is there a more generic way to acomplish this task..??
On 15 dic, 08:35, "Greg Hile" <[email protected]> wrote: > Since I never took a course on programming I'll give you my Neaderthalic way > of doing it. > > I think I would load the whole thing into a string reader and do a ReadLine > on it to get each line of the text. > Something like this. > > StringReader sr = new StringReader(yourString); > string currentText = sr.ReadLine(); > while(currentText != null) > { > if (currentText.Contains("NAM*OFFICE NAME")) > { > string[] textInfo = currentText.Split('-'); > string officeName = textInfo[1].Trim(); > } > if (currentText.Contains("AD1*ADDRESS 1")) > { > string[] address1 = currentText.Split('-'); > string result = address1[1].Trim(); > } > currentText = sr.ReadLine(); > //etc.......... > > } > > Hopefully this was of some use to you. > In the meantime I'll just keep "club coding" along! > GregH > > > > > > > > -----Original Message----- > From: [email protected] > > [mailto:[email protected]] On Behalf Of Anchit Kathuria > Sent: Tuesday, December 14, 2010 7:43 AM > To: DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web > Services,.NET Remoting > Subject: [DotNetDevelopment] VERY URGENT, PLEASE HELP! > > Hi, > I have got the following XML test in a string variable: > > string str is assigned the following value : > "<Cryptic_GetScreen_Reply><CAPI_Screen><Response>* * * * * * * * * * * > * PV OFFICE PROFILE * * * * * * * * * * > AMADEUS OFFICE ID - YYZ6W210X AMID - 288365 > NATIONAL SYSTEM OFFICE ID - 1S/10019368 > DATE/TIME - 02NOV10/1239 > > * * * * * * * * * * * * OFFICE IDENTIFICATION * * * * * * * * > CIN*IATA NUMBER - 67906602 - PRIMARY > ERN*ERSP NUMBER - 00000000 > CCO*CALL CENTER OFFICE - NO > * * * * * * * * * * * * GENERAL DATA * * * * * * * * * * * * > NAM*OFFICE NAME - CUMBERLAND TRAVEL > AD1*ADDRESS 1 - 2200 MARKHAM ROAD, UNIT 1 > AD2*ADDRESS 2 - NONE > AD3*CITY NAME - SCARBOROUGH, ON M1B 2W4 > CRP*CORPORATE IMPLANT- NONE > CTN*COUNTRY NAME - CANADA > PHO*PHONE PRIMARY - 416 250-6200 > PH2*PHONE SECONDARY - NONE > FAX*FAX PRIMARY - 416-250-6205 > FA2*FAX SECONDARY - NONE > EML*EMAIL ADDRESS - NONE > OOH*OPENING HOURS - M 1): OPEN ALL DAY > )></Response></CAPI_Screen></Cryptic_GetScreen_Reply>" > > Now, can you please tell me a way to get the values of various fields (in > above text) from the string. I have already tried using "split" > function and Regix function on this string but it was getting too > complicated. May be there is a way to insert this into an XML Document > object? I need to insert the VALUES from above string into a DB table (using > ADO.NET). How can I get only the values from above string? (eg: > YYZ6W210X, 288365, 1S/10019368 etc.)
