How to insert new line in xml?

 I have an xml like below and wanted to insert a new line between end of the tag and start of the new tag.
<partyaddress><addressline1>gandhi  stree</addressline1><city>hyderbad</city><state>AP</state><addressline1>xyz  stree</addressline1><city>bangalore</city><state>Karnataka</state> </partyaddress>

I wanted the output like below

<partyaddress>
<addressline1>gandhi  stree</addressline1><city>hyderbad</city <state>AP</state>
<addressline1>xyz   stree</addressline1><city>bangalore</city><state>Karnataka</state>  </partyaddress>
I am trying the code like below but in vain
sed "s/</\state>/<\/stae>\n/g" a.xml
rather than getting a new line, "n" is being added to it.
OS: HP UNIX
SHELL: ksh

Could you please help me out to get the output as specified above?



Try puting the sed expression in single quotes instead of double quotes.

sed "s/</\state>/<\/stae>\\
/g" a.xml

or try

# sed 's/<addressline1/\
> <addressline1/g'

Thanks, it is working with \\, but not working with single codes.Thanks
Once again

You may try awk

$ awk '{sub("<"tag">","&\n");sub("</"tag">","\n&")}1' tag="partyaddress" file.xml

<partyaddress>
<addressline1>gandhi  stree</addressline1><city>hyderbad</city><state>AP</state><addressline1>xyz  stree</addressline1><city>bangalore</city><state>Karnataka</state> 
</partyaddress>
sed 's/</\state>/<\/stae>\
/g' a.xml