Unix/Linux 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 Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 10:30 AM.. Reason: Please use code tags. NOTE: I added a missing < before /Name>
Sponsored Links
    #2  
Old Unix and Linux 01-16-2013
Yoda's Unix or Linux Image
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 20 April 2015, 6:16 PM EDT
Location: Galactic Empire
Posts: 3,402
Thanks: 240
Thanked 1,216 Times in 1,142 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image 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 09:29 PM
Solaris Attribute Problems jimcz2it Solaris 2 01-29-2012 04:05 PM
Password Attribute avklinux Red Hat 2 06-09-2009 05:52 PM
Dynamic Attribute Changes er_aparna Shell Programming and Scripting 8 10-30-2006 11:57 PM
File attribute Help please Cube3k Linux 1 12-15-2003 04:31 PM



All times are GMT -4. The time now is 04:17 AM.