Sed print range of lines between line number and pattern

Hi,

I have a file as below

This is the line one
This is the line two
<\XMLTAG>
This is the line three
This is the line four
<\XMLTAG>

Output of the SED command need to be as below.

This is the line one
This is the line two
<\XMLTAG>

Please do the need to needful to get the desired output. I tried with sed -n '1,/<\XMLTAG>/p' filename, it is printing the whole file

Thanks
RMN

sed -n '1,3p' infile

Can you please tell me the regex for the end position to match the first occurance of the <\XMLTAG> and print the lines from 1 to first occurance of
<\XMLTAG>

Your initial attempt was close. The backslant (\) needs to be escaped:

sed -n '1,/<\\XMLTAG>/p'

Thanks a load agama.:b: