LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-02-2015, 08:43 AM   #1
boby.kumar
Member
 
Registered: Mar 2013
Posts: 94

Rep: Reputation: Disabled
Extract values between xml tag


Hi,
I am getting a output in xml file likes this
<?xml version="1.0" encoding="UTF-8"?><IO><USER><PHONEPROFILE><msisd>abc1256766</msisd></PHONEPROFILE></USER><AUDIT><reason>yediuyeiyeieoeyeo</reason><userId>eyt</userId><organisat>hedhkjerkiffkk</organisat><systemId>ueieuoieuoeoeue</systemId></AUDIT></IO

I want to get the values from the xml tag like abc1256766 from
<msisd>abc1256766</msisd>. and also get the encoding values as UTF-8 from this <?xml version="1.0" encoding="UTF-8"?> tag.

I am trying to get the above with sed utility over solaris and get the following error-
Code:
 grep -E -m 1 -o "<msisdn>(.*)</msisdn>" a.xml
grep: illegal option -- E
grep: illegal option -- m
Usage: grep -hblcnsviw pattern file . . .
Can someone correct me how to get this exactly ?

Thanks
 
Old 11-02-2015, 08:57 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 13,082

Rep: Reputation: 4137Reputation: 4137Reputation: 4137Reputation: 4137Reputation: 4137Reputation: 4137Reputation: 4137Reputation: 4137Reputation: 4137Reputation: 4137Reputation: 4137
is this about sed or grep? The grep on solaris has different syntax, you need to check the man page of it.
what kind of solaris and grep do you have (version ???)
 
Old 11-02-2015, 10:31 AM   #3
lambo69
Member
 
Registered: Sep 2012
Distribution: Slackware, Debian, Slackarm, Raspbian
Posts: 55

Rep: Reputation: Disabled
Are you depending on grep/sed? Using an XPath in e.g. xmllint would be easier.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Trying to parse a value from XML tag for a variable n3wtux Linux - Newbie 1 07-26-2013 04:51 PM
how to add xml-stylesheet tag in a XML File using libxml2 ? peacemission Programming 6 05-26-2012 02:20 AM
Print xml tag only if lenght > 0 frambau Programming 5 02-13-2012 05:10 AM
Adding new tag to an xml file using sed nano2 Linux - General 6 11-23-2011 05:47 AM
How To get the data from a tag in XML File kingmaker2003 Programming 7 12-04-2008 11:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration