API Based URL Parsing


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting API Based URL Parsing
# 1  
Old 10-04-2013
API Based URL Parsing

Hi Friends,
We have a situation where we need to pass API based URL which will return XML response ,and I need to convert those XML response to a delimited flat file.

Code:
url.txt -- will have
http://xyz.com/beta/xxx.xml?isDRR=True&city=London&province=England
http://xyz.com/beta/xxx.xml?isDRR=&latitude=40.7611&longitude=-73.9853

Need a program which will read the url.txt and parse the XML response to a delimited flat file

Sample XML Response:

<Response>
<col1>159.3</col1>
<col2>17.8111</col2>
</Response>

<Response>
<col1>1.3</col1>
<col2>1.11</col2>
</Response>

Required OutPut

col1|col2
159.3|17.8111
1.3|1.11

I think we can do it by using perl but have no clue about the URL & XML parsing.

Any help ...!!!
# 2  
Old 10-04-2013
you may try this awk version

Code:
$ awk -F'[<,>]' 'BEGIN{print "col|col2"}/<col/{i++;printf (i==1)? $3 OFS:  $3 "\n"}{i=(i!=1)?0:i}' OFS="|"  file
col|col2
159.3|17.8111
1.3|1.11

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File Parsing based on a character in a specific field

Hi All, I'm having a hard time finding a starting point for my issue. I have a 30k line file (fspsec.txt) that I would like to parse into smaller files based on any character existing in field 1. ACCOUNTANT LEVEL 1 (ACCT.ACCOUNTANT) OPERATORS: DOEJO (418) TOOLS: Branch Maintenance ... (2 Replies)
Discussion started by: aahlrich
2 Replies

2. Shell Programming and Scripting

Parsing a file based on positional constraints

I have a list file1 like dog cow fox cat fish duck crowI want to classify the elements of file1 based on constrains applied on file2. Additionally the number of elements (words) in the each line of file2 is not fixed. This is my file2 cow cat fox dog cow fox dog fish crow fox dog cat ... (5 Replies)
Discussion started by: sammy777
5 Replies

3. Shell Programming and Scripting

Parsing a file based on next line

I have a file1 like ID E2AK1_HUMAN Reviewed; 630 AA. CC -!- SUBCELLULAR LOCATION: Host nucleus {ECO:0000305}. ID E1A_ADEM1 Reviewed; 200 AA. ID E1A_ADES7 Reviewed; 266 AA. CC -!- SUBCELLULAR LOCATION: Host nucleus... (8 Replies)
Discussion started by: sammy777
8 Replies

4. Web Development

Mod_rewrite - URL rewrite based upon HTTP_REFERER

Hello, I have added following rewrite cond and rewrite rules but it does not work. RewriteCond %{HTTP_REFERER} ^http://192\.168\.1\.150/categories/.*$ RewriteRule ^(.*)$ http://www.blahblah.com/ When I hit url : http://192.168.1.150/categories/881-Goes?page=7 in my browser - it... (2 Replies)
Discussion started by: ashokvpp
2 Replies

5. Post Here to Contact Site Administrators and Moderators

Page Not Found error while parsing url

Hi I just tried to post following link while answering, its not parsing properly, just try on your browser Tried to paste while answering : https://www.unix.com/302873559-post2.htmlNot operator is not coming with HTML/PHP tags so attaching file (2 Replies)
Discussion started by: Akshay Hegde
2 Replies

6. Shell Programming and Scripting

Need to run an API from a script and extract fields from output of API

Hi, I need to call an API (GetUsageDetails)from inside a shell script which takes an input argument acct_nbr. The output of API will be like : <usageAccum accumId="450" accumCaptn="PM_125" inclUnits="1410.00" inclUnitsUsed="744.00" shared="true" pooled="false" prorated="false"... (1 Reply)
Discussion started by: rkrish
1 Replies

7. Shell Programming and Scripting

Using md5sum to name file based on URL

I am trying to download a file and make the filename of the file be the md5sum of the URL. I know to use wgets to download the file but I do not know how to do the rest...any help would be appreciated. (2 Replies)
Discussion started by: The undertaker
2 Replies

8. Shell Programming and Scripting

parsing file based on characters/bytes

I have a datafile that is formatted as fixed. I know that each line should contain 880 characters. I want to separate the file into 2 files, one that has lines with 880 characters and the other file with everything else. Is this possible ? (9 Replies)
Discussion started by: cheeko111
9 Replies

9. Web Development

Regex to rewrite URL to another URL based on HTTP_HOST?

I am trying to find a way to test some code, but I need to rewrite a specific URL only from a specific HTTP_HOST The call goes out to http://SUB.DOMAIN.COM/showAssignment/7bde10b45efdd7a97629ef2fe01f7303/jsmodule/Nevow.Athena The ID in the middle is always random due to the cookie. I... (5 Replies)
Discussion started by: EXT3FSCK
5 Replies

10. Shell Programming and Scripting

parsing url string

Hi, I have a url like this:- http://resource.ibab.ac.in/cgi-bin/pubmed_abstract/y.cgi?pmid=+1.10529272+&pmid=+3.8379586 I want to parse the url string.I want to get the values 1.10529272 3.8379586 How do i do that? (5 Replies)
Discussion started by: vanitham
5 Replies
Login or Register to Ask a Question