Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to retrieve specied string from text file
#1
I have a txt file content is as follows
Code:
10.76.34.61 10.76.177.138 NULL POST /a2asoa/v2008/001/Security.asmx <REQ><OP>IsUserIdAvailable</OP><SOAP><userID>shawnandersonxnet</userID><pwd>****</pwd><sourceid>1012</sourceid><searchUserID>cwclvickers1</searchUserID><languageID>1</languageID></SOAP></REQ> 16 4000 200 0 931 931 NULL 89998 1 2015-06-03 14:26:17.257 3000 137580 0 10.76.34.61 10.76.177.138 NULL POST /a2asoa/v2008/001/Security.asmx <REQ><OP>GetSecLevelsFunctions</OP><SOAP><userId>shawnandersonxnet</userId><pwd>****</pwd><sourceid>1012</sourceid><searchSecLevels>17497</searchSecLevels><showInactiveSecLevels>0</showInactiveSecLevels><template>0</template><languageId>1</languageId></SOAP></REQ> 125 4000 200 0 1905 1905 NULL 91168 1 2015-06-03 14:33:10.350 3000 137580 0 10.76.34.223 10.76.177.141 NULL POST /a2asoa/v2008/001/Notifications.asmx <REQ><OP>GetClientConfig</OP><SOAP><sourceid>346</sourceid><userid>budcsa</userid><pwd>****</pwd><msgType>EMAIL</msgType><cardNumber>******7507804998</cardNumber><clientid></clientid><programid></programid><subProgramid></subProgramid></SOAP></REQ> 16 1000 200 0 958 958 NULL 72264 1 2015-06-03 07:58:27.657 1000 659 0 10.76.34.161 10.76.177.141 NULL POST /a2asoa/v2008/001/Security.asmx <REQ><OP>GetSecLevelsFunctions</OP><SOAP><userId>shawnandersonxnet</userId><pwd>****</pwd><sourceid>1012</sourceid><searchSecLevels>2732,2732</searchSecLevels><showInactiveSecLevels>0</showInactiveSecLevels><template>0</template><languageId>1</languageId></SOAP></REQ> 94 4000 200 0 841 841 NULL 37690 1 2015-06-03 15:26:35.080 3000 137580 0 10.76.34.61 10.76.177.138 NULL POST /a2asoa/v2008/001/Client.asmx <REQ><OP>GetAuthorizedClientTree</OP><SOAP><userId>shawnandersonxnet</userId><pwd>****</pwd><sourceid>1012</sourceid><clientId></clientId><clientNamePattern></clientNamePattern><startRow></startRow><stopRow></stopRow><languageId>1</languageId></SOAP></REQ> 7781 3500 200 0 1905 1905 NULL 94484 1 2015-06-03 15:26:49.083 3000 137580 0

From this file i want to retrieve the value from the element sourceid
for Eg.
Code:
<sourceid>1012</sourceid> From this i want 1012 alone
Reply
#2
Hi Team, I found the solution
Sample.txt contains the above content
Code:
Dim fso Set fso = CreateObject("Scripting.FileSystemObject") Set objTxtFile = FSO.OpenTextFile("C:\Users\Suresh\Desktop\sample.txt") i=0 Do Until objTxtFile.AtEndOfStream sContent = objTxtFile.ReadLine sContent= replace(sContent,"<sourceid>","sourceid=") sContent= replace(sContent,"</sourceid>","@sourceid") a=instr(sContent,"=") a=a+1 b=instr(sContent,"@") c=b-a sContent=Mid(sContent,a,c) print sContent i = i+1 Loop
Hope it will help someone
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error as Global Not defined while trying to retrieve value from Datatable siddharth1609 0 1,338 09-11-2019, 02:52 PM
Last Post: siddharth1609
  Cannot retrieve Native property JeL 1 1,565 07-29-2019, 05:41 PM
Last Post: JeL
  Need to Validate Text filed is blank after clicking on the Text box balak89 3 5,917 09-13-2015, 12:06 AM
Last Post: ADITI1992
  To retrieve content of a WEBEDIT object alpha1 2 3,313 06-11-2015, 11:21 AM
Last Post: vinod123
  Retrieve row number based on value in DataTable marfa 6 32,361 07-31-2014, 08:36 PM
Last Post: dharshinishankari@gmail.com

Forum Jump:


Users browsing this thread: 1 Guest(s)