I have an XML file of the format:
<classes>
<subject lb="Fall Sem 2020">
<name>Operating System</name>
<credit>3</credit>
<type>Theory</type>
<faculty>Prof. XYZ</faculty>
</subject>
<subject lb="Spring Sem 2020">
<name>Web Development</name>
<credit>3</credit>
<type>Lab</type>
</subject>
<subject lb="Fall Sem 2021">
<name>Computer Network</name>
<credit>3</credit>
<type>Theory</type>
<faculty>Prof. ABC</faculty>
</subject>
<subject lb="Spring Sem 2021">
<name>Software Engineering</name>
<credit>3</credit>
<type>Lab</type>
</subject>
</classes>
Expected Output:
Fall Sem 2020
Spring Sem 2020
Fall Sem 2021
Spring Sem 2021
I want to extract the values of lb
in an array.
My try: I tried using sed -n "/lb="/,\/"/p" file.xml
but this command is not giving me the values present for the particular label.
What could be the correct way to deal with this problem?