How to use xml_grep to get the value of an attribute? | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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 !!

How to use xml_grep to get the value of an attribute?

UNIX for Dummies Questions & Answers


Tags
attribute, tag, unix, xml

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-16-2013
pistach pistach is offline
Registered User
 
Join Date: Nov 2012
Last Activity: 23 September 2013, 10:36 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
How to use xml_grep to get the value of an attribute?

I'm using xml_grep command to get the value of different tags in a xml-file.
No i also need the value of an attribute in a tag.
Can I use xml_grep for this? Does anybody know how?
ex. :

Code:
 
<Name xmlns:xsi="http://www.w3.org/2001/XMLinst" xsi:spaceSchema="Name_5879.xsd">
...
</Name>

I need the value of xsi:spaceSchema > Name_5879.xsd

Last edited by Scott; 01-16-2013 at 11:30 AM.. Reason: Please use code tags. NOTE: I added a missing < before /Name>
Sponsored Links
    #2  
Old 01-16-2013
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 26 November 2014, 4:40 PM EST
Location: Galactic Empire
Posts: 3,389
Thanks: 236
Thanked 1,210 Times in 1,136 Posts
I'm not sure about using xml_grep, below is an awk program to get the value of attribute:-

Code:
awk -F"=" '{for(i=1;i<=NF;i++) { if($i~/xsi:spaceSchema/) v=$(i+1); } } END { gsub(/"|>/,"",v); print v; } ' xml

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
ldapclient can not modify attribute alfa_w Solaris 0 04-05-2012 10:29 PM
Solaris Attribute Problems jimcz2it Solaris 2 01-29-2012 05:05 PM
Password Attribute avklinux Red Hat 2 06-09-2009 06:52 PM
Dynamic Attribute Changes er_aparna Shell Programming and Scripting 8 10-31-2006 12:57 AM
File attribute Help please Cube3k Linux 1 12-15-2003 05:31 PM



All times are GMT -4. The time now is 05:49 PM.