I have an XML file of the format:
<classes>
<subject>
<name>Operating System</name>
<credit>3</credit>
<type>Theory</type>
<faculty>Prof. XYZ</faculty>
</subject>
<subject>
<name>Web Development</name>
<credit>3</credit>
<type>Lab</type>
</subject>
</classes>
I want to store the tag names i.e. name, credit, type, faculty in an Array using Shell Script.
I tried using awk command as:
awk -F'[<>]' '/<name>|<credit>|<type>|<faculty>/{print $2}' file.xml
But it's returning values as:
name
credit
type
faculty
name
credit
type
How to store these results in an array?