ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
You could try to write a regular expression to do this, but parsing xml, html, etc. is notoriously difficult. If ksh is like Bash in terms of syntax, that sounds like trying to sculpt a piece of marble with a spoon. I would recommend looking at a scripting language with XML parsers available (eg, Perl, Python or Ruby).
You could try to write a regular expression to do this, but parsing xml, html, etc. is notoriously difficult. If ksh is like Bash in terms of syntax, that sounds like trying to sculpt a piece of marble with a spoon. I would recommend looking at a scripting language with XML parsers available (eg, Perl, Python or Ruby).
I think we can get with awk ... I got the answer but works with 1st occurance of the <EmailAddress></EmailAddress> tag only
Code:
awk -F '</?EmailAddress>' '{print $2}' 456.xml
but i need for multiple times .... means email address tag exists for multiple times in the file ...
so need to check whole xml file for email address wherever <EmailAddress></EmailAddress> tag is present.
Last edited by kingmaker2003; 12-03-2008 at 02:42 PM.
I think we can get with awk ... I got the answer but works with 1st occurance of the <EmailAddress></EmailAddress> tag only
Code:
awk -F '</?EmailAddress>' '{print $2}' 456.xml
but i need for multiple times .... means email address tag exists for multiple times in the file ...
so need to check whole xml file for email address wherever <EmailAddress></EmailAddress> tag is present.
Take a look at egrep's multiline/return regex searching. It will allow you to parse the file for each occurrance of <></> and then pipe that to another egrep that uses -v and looks for <></>.
I concur with Telemachos and Chrism01. Do yourself a big favor, and learn just enough Perl to parse a little bit of your file. Then see how easy it is to call Perl from your script. Just try it - and I think you'll concur, too.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.