0

Planning to add the below content after the closing tab into the main.xml

Keeping the below xml tag information into the ADD.txt file.

<student>
    <name>Bob</name>
    <id>0111</id>
     -----
</student>

Executing the following command: The information is adding above the tag </class>, Planning to add the ADD.txt content after the tag </class>

sed -i '/</class>/e cat ADD.txt' main.xml

Bob
  • 3
  • 2
  • `sed -i '/<\/class>/r ADD.txt' main.xml` ? – jhnc Jul 08 '22 at 22:12
  • content is not adding before or after the xml tag once we use "r" – Bob Jul 11 '22 at 13:53
  • working fine now - we have to give space between "/ and r" sed -i '/<\/class>/ r ADD.txt' main.xml – Bob Jul 11 '22 at 14:03
  • Use a real XML parser such as [xml-starlet](https://stackoverflow.com/q/5954168/290085) to parse XML, not regex. Why? See [Why it's not possible to use regex to parse HTML/XML: a formal explanation in layman's terms](https://stackoverflow.com/questions/6751105/why-its-not-possible-to-use-regex-to-parse-html-xml-a-formal-explanation-in-la) – kjhughes Mar 02 '23 at 12:34

0 Answers0