Parsing posted XML data from a remote server?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Parsing posted XML data from a remote server?
# 1  
Old 11-07-2009
Parsing posted XML data from a remote server?

Hi
Is it possible to parse a posted xml data from a remote server in unix shell script. if so how to do that? and i need to give this script path in the push url (in remote server) . how to do this?

I have tried this in asp but could not succeed....so am trying in shell scripting...the thread opened in asp forum is available in this link
Parsing XML data - ASP Free

Please help me
# 2  
Old 11-07-2009
Here a little script i commited yesterday for personal use.
Code:
XmlRead ()	{	# [1:(-v:verbose)]	2:branch to explore 3:Tag de fin
	ReadTag ()	{
		read L || return 1
		T=$(echo ${L%%>*>} | sed -e 's/[<>]//g' -e 's/:/_/g')
	}
	[ -n "$3" ] && OPT="$1" && shift
	local T=""
	local V=""
	while ReadTag
	do
		[[ $T = $2 ]] && break
		[[ $T != $1 ]] && continue
		[ "$OPT" = "-v" ] && echo "Tag: $T"
		while ReadTag
		do
			[[ $T = "/$1" ]] && break
			V=$(echo $L | sed s/"<[^>]*>"/""/g)
			if [[ -n "$V" ]]
			then	eval "$T=\"$V\""
				[ "$OPT" = "-v" ] && echo "$T=$V"
			else [ "$OPT" = "-v" ] && echo "Tag: $T"
			fi
		done
		[ "$OPT" = "-v" ] && echos 50 "-"
		return 0
	done
	return 1
	}

The script is called with following parameters :
1: -v to verbose, for testing and debugging purposes, outputs the variable names and values
2:subtree to explore i.e "data" will parse everithing in the subtree beginning with <data> and ending with </data>
3:endtag : permits to exit before the end of parsed file
the function returns false if EOF or endtag is reached.
possible usage
Code:
while ReadXml -v "data" "endofdata"
do
     something
     ...
done < $XmlFile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script connect to remote server, not find files and exit only from remote server, but not from scrip

I have a script, which connecting to remote server and first checks, if the files are there by timestamp. If not I want the script exit without error. Below is a code TARFILE=${NAME}.tar TARGZFILE=${NAME}.tar.gz ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly;... (3 Replies)
Discussion started by: digioleg54
3 Replies

2. Shell Programming and Scripting

Parsing custom data into xml in Shell

Hi , I have data as below in a text file { 'AAA' => { 'A1' => 'a1 comment', 'A2' => 'a2 comment' }, 'BBB' => { 'B1' => 'b1 comment' }, 'CCC' => { 'C1' => 'c1 comment', 'C2' => 'c2 comment', 'C3' => 'c3 comment' 'C4' => 'c4... (2 Replies)
Discussion started by: vivek d r
2 Replies

3. Shell Programming and Scripting

Parsing XML (and insert data) then output data (bash / Solaris)

Hi folks I have a script I wrote that basically parses a bunch of config and xml files works out were to add in the new content then spits out the data into a new file. It all works - apart from the xml and config file format in the new file with XML files the original XML (that ends up in... (2 Replies)
Discussion started by: dfinch
2 Replies

4. Shell Programming and Scripting

XML: parsing of the Google contacts XML file

I am trying to parse the XML Google contact file using tools like xmllint and I even dived into the XSL Style Sheets using xsltproc but I get nowhere. I can not supply any sample file as it contains private data but you can download your own contacts using this script: #!/bin/sh # imports... (9 Replies)
Discussion started by: ripat
9 Replies

5. Shell Programming and Scripting

Help - Parsing data in XML in Linux

Hi, I have an XML file in Linux and it contains a long string of characters. The last part of the file is like ....... ....... ....... CAD</MarketDescription></InvestorTransaction></AdvisorAccount></DivisionAdvisor></Division>... (3 Replies)
Discussion started by: naveed
3 Replies

6. Programming

Sending and Receiving data between Client, HTTP Proxy, and Remote Server

I am having problems receiving data from a remote server. It seems that I can send an HTTP request to any host such as http://www.google.com, but I can't get a reply. I'm sending the host a HTTP 1.0 request that is formatted as such: GET / HTTP/1.0 Host: http://www.google.com Connection:... (0 Replies)
Discussion started by: shubham92
0 Replies

7. Shell Programming and Scripting

Using SFTP and FTP to transfer data from One Remote Server To Another

HI I need to write a script in 415univ server which should go to 534unix server and move the files from there to windows server. I am not able to get it bcoz sftp prompt is not allowing ftp command. Can some one plz help me Thanks in advance (3 Replies)
Discussion started by: himakiran9
3 Replies

8. Shell Programming and Scripting

parsing data from xml file is failing can't open variable

Created a korn shell script, everything is is working except this section, the variable $SYSINFO is being set, but the NASIP & NASDEV are failing, it appears to be treating the config.xml file config directory and xml as the file. Need a second set of eyes to tell me where I am messing up. #... (3 Replies)
Discussion started by: juanb25
3 Replies

9. Shell Programming and Scripting

Parsing and getting data from XML file using ksh script

Hi All, I have a xml file for example as described below <xml> <address> <street><street> <address/> <isbn>426728783932020308393930303</isbn> <book> <name> </name> </book> . . . </xml> My problem is to get the isbn number from the above described file using ksh script. Could... (6 Replies)
Discussion started by: vinna
6 Replies

10. UNIX for Dummies Questions & Answers

Parsing XML dynamic data via awk?

I am trying to use a line of output in an XML file as input in another new XML file for processing purposes via a shell script. Since I am a newbie though, I'm not sure how to do this since the data is different everytime. I am using this technique with static data right now: echo -n "Running... (5 Replies)
Discussion started by: corwin43
5 Replies
Login or Register to Ask a Question