How to get data from xml files tags(from data tags)
hi I have a tag in XML file in unix like this
<EmailAddress>abc@gmail.com</EmailAddress> this tag is there for multiple times in the xml file and the data is in continuous line like below <State>UN</State><Zip/><CompanyName/><EmailAddress>FDF@gmail.COM</EmailAddress><PromoType>UNKNOWN</PromoType></Promotion></PromotionList<State>UN</State><Zip/><CompanyName/><EmailAddress>zd4946@gmail.com</EmailAddress> I have to check the data in between bold tags is valid or not ... means have to check whether its a email address or not and have to find the length of the attribute means tag ...script is in ksh sorry if its already asked...i checked but i didnt get Exatly matching result for my requirement any help in this |
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).
|
Quote:
Code:
awk -F '</?EmailAddress>' '{print $2}' 456.xml so need to check whole xml file for email address wherever <EmailAddress></EmailAddress> tag is present. |
Concur with Telemachos
|
Quote:
|
|
Quote:
|
kingmaker2003 -
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. IMHO .. PSM |
All times are GMT -5. The time now is 09:42 AM. |