extract a pattern from a xml file

Hello All,

I want to write a shell script for extracting a content from a xml file

the xml file looks like this:

<Variable name="moreAxleInfo">

							<type>

								<Table>

									<type>

										<NamedType>

											<type>

												<TypeRef name="LMI::LMI_EditBoxStatus_t"/>

											</type>

										</NamedType>

									</type>

									<size>

										<IdExpression>

											<path>

												<ConstVarRef name="LMI::NOOFNUMBOXAXLE"/>

											</path>

										</IdExpression>

									</size>

								</Table>

							</type>

							<pragmas>

								<ed:Variable oid="!ed/22db66/6665/464/4ed4be3e2af6"/>

							</pragmas>

						</Variable>

when the Variable name=m/M then just extract the variable name.

Like this?

sed -n '/<Variable name="[mM]/,/<\/Variable>/{
s/.*=\("[^"]*"\).*/\1/
t prnt
b
:prnt
p
}' file

trying to execute the same but it is throwing this error:
sed -n '/<Variable name="[mM]/,/<\/Variable>/{s/.*=\("[^"]*"\).*/\1/t prntb :prntp}' file

throwing the below error:
sed: -e expression #1, char 62: unknown option to `s'

Execute the command as I have given. Don't remove the line-breaks.

@elixir_sinari: your command will output all double quoted strings in that file fragment. Omiting the end of the address range (,/<\/Variable>/) will output the variable name only, as desired.

Thanks for the information its working......

Let me know what i shall use if i want to extract all the contents which starts with a capital letter like:
<Variable name="moreAxleInfo">...it shall not be extracted
<Variable name="MoreAxleInfo">....it shall be extracted....
<Variable name="JklAxleInfo">........it shall be extracted...
<Variable name="oklAxleInfo">...it shall not be extracted

RudiC, the OP's requirement was not very clear to me. I assumed that he wants only those strings which he has highlighted in a different colour.

Replace the [mM] in elixir_sinari's command by [A-Z].

No if i am replacing mM with A-Z but it is not working....

I just want to search for:
1)<Variable name="jkasjklasfkljl">
2)If the name starts with capital letter then just extract it......

Apart from this i dont want anything else......
Other attribute it shall not check also.

Try this for your very simple (seemingly) requirement:

sed -n '/<Variable name="[A-Z]/p' file

No it doesnot work.
It seems some problem with the command...
It doesnot print anything in the shell....

Any other suggestion please

sed -n '/<Variable name="[A-Z]/p'  input.xml

works fine if you have variables, which start letter A-Z

Or

sed -n '/<Variable name="[[:upper:]]/p'

Or try [a-z] or [[:lower]].