![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Capturing stdin | domivv | Shell Programming and Scripting | 3 | 01-24-2008 01:30 PM |
| capturing log | mgirinath | Shell Programming and Scripting | 3 | 05-16-2006 08:21 AM |
| Capturing text between () | sysera | Shell Programming and Scripting | 7 | 06-14-2005 08:37 AM |
| Capturing value into variable | prasad01 | Shell Programming and Scripting | 2 | 08-19-2003 12:38 PM |
| capturing process id | bvreddy | Shell Programming and Scripting | 1 | 09-16-2002 01:08 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hi All,
I have an XML-: Code:
<ProcId>CES_P5010_AddVLan</ProcId>
<DataVersion>yxcxycyxcycyxc</DataVersion>
<JobId>OR3000055-002-1</JobId>
</CesHeader>
<VLanServiceList>
<NopId>blu</NopId>
</VLanServiceList>
<StatusNPA>2</StatusNPA>
<ErrorTextNPA>Exception occurred trying to create Management Service :Exception occurred trying to create Service :Error Code=239023 [Virtual LAN: ].. ** </ErrorTextNPA>
</NPAErrorHandling>
</CesResponse>
Here I want to have a shell script to get the string in the tag <ErrorTextNPA>*****<ErrorTextNPA>. Can any one help me on this. Regards Amit Last edited by Yogesh Sawant; 05-14-2008 at 04:17 AM. Reason: added code tags |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Is this a single long line, or spanning over multiple lines?
As such, the following doesn't really care. Code:
perl -0777 -pe 's%.*<ErrorTextNPA>%%s;s%</ErrorTextNPA>.*%%s' file |
|
#3
|
||||
|
||||
|
moved the thread from solaris to shell scripting for this is not a solris specific question...
|
|
#4
|
|||
|
|||
|
using sed,
cat filename | grep -e '<ErrorTextNPA>' | sed 's/<ErrorTextNPA>\(.*\)<\/ErrorTextNPA>/\1/' Thanks Penchal |
|
#5
|
|||
|
|||
|
Actually the cat and grep are redundant.
Code:
sed -n 's%.*<ErrorTextNPA>\(.*\)</ErrorTextNPA>.*%\1%p' file.xml |
|
#6
|
|||
|
|||
|
Quote:
I would note that this is not possible for the supplied XML document since it is not a well-formed or valid XML document (missing root, missing opening tags, etc.) |
|||
| Google The UNIX and Linux Forums |