![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Authorizing Access to Dynamic Spatial-Temporal Data | iBot | Oracle Updates (RSS) | 0 | 04-18-2008 06:10 PM |
| parsing data file picking out certain fields | timj123 | Shell Programming and Scripting | 8 | 03-05-2008 06:57 PM |
| Parsing and getting data from XML file using ksh script | vinna | Shell Programming and Scripting | 6 | 12-08-2007 01:10 PM |
| Parsing the data in a file | Omkumar | Shell Programming and Scripting | 2 | 05-20-2005 08:59 AM |
| search and replace dynamic data in a shell script | csejl | Shell Programming and Scripting | 8 | 10-21-2003 10:33 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 data test... " cat datafile.xml | sed -e s/changethis/intothis/ > /tmp/$$.xml export RESULT=`~/xml /tmp/$$.xml | grep "<Code>SUCCESS</Code>"` if [ "$RESULT" != "" ]; then { echo passed } else { echo FAILED ; exit } fi The XML file has the data I need stored between XML tags, so I know I could grep that line and output it to another file, and use that file to refer to for the input in the next test. That file would have < Number >here'sthedata< /Number > in that file. The trick would be to parse the data out, in effect removing the tags, storing that value in a variable, and then using sed to do a replace in the new input file like I am above. I'm just unsure how to go about parsing the data out. Hope this wasn't confusing ![]() Last edited by corwin43; 11-01-2001 at 04:02 PM.. |
|
|||||
|
Well... if you don't mind going to Perl, (I would recommend this)
you can use the XML::Parser Perl module... http://wwwx.netheaven.com/~coopercc/...ser/intro.html ...it would be alot more flexable and in the long run, I think you'll need that anyway. ![]() |
|
||||
Actually a colleague here is trying to push these scripts over to Perl (mainly because he more comfortable with Perl than shell scripting). To be bluntly honest, I'm a Windows guy (ducks....) and my new job responsibilites are forcing me to pick this up on the fly. From the little exposure I've had to Perl, it probably would work more elegantly, but these testing scripts are all compelte except the one I'm having a problem on, and the ole 'time constraints' make it problematic to rewrite everything in Perl right now. I do plan on doing that eventually, but for now I need this up and running in the shell environment.(bash bash bash) ![]() |
|
|||||
|
PERL is really not so difficult to learn and there must be hundreds of samples on the net for how to build PERL::XML transformations:
PERL XML FAQ XMLperl And so much more: Google search |
|
|||||
|
Damn...
The XML strings disappeard in the previous post... Note I changed all the angle brackets "<" to square brackets "[". you'll have to translate them back. script... #!/bin/sh awk '/[Number]/ {stp=index($0,">")+1; \ newstr=substr($0,stp); \ etp=index(newstr,"<")-1; \ print substr(newstr,0,etp); \ }' test.xml test.xml [String]one[/String] [Number]two[/Number] [String]three[/String] [Number]four[/Number] ![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|