linux - Bash, Remove empty XML tags -


I need to help a few questions using the Bash Tools

  1. Exempt XML tags from want file:
  & lt; CreateOfficeCode & gt; & Lt; OperatorId> Ve & lt; / OperatorId> & Lt; OfficeCode & gt; 1234 & lt; / OfficeCode & gt; & Lt; CountryCodeLength & gt; 0 & lt; / CountryCodeLength & gt; & Lt; AreaCodeLength & gt; 3 & lt; / AreaCodeLength & gt; & Lt; Properties & gt; & Lt; / Properties & gt; & Lt; ChargeArea & gt; & Lt; / ChargeArea & gt; & Lt; / CreateOfficeCode & gt;  

To be created:

  & lt; CreateOfficeCode & gt; & Lt; OperatorId> Ve & lt; / OperatorId> & Lt; OfficeCode & gt; 1234 & lt; / OfficeCode & gt; & Lt; CountryCodeLength & gt; 0 & lt; / CountryCodeLength & gt; & Lt; AreaCodeLength & gt; 3 & lt; / AreaCodeLength & gt; & Lt; / CreateOfficeCode & gt;  

For this, I did this with this command

  sed -i '/> & Lt; \ // d 'file  

Which is not so strict, the more moves it has, the more appropriate & lt; Pattern & gt; & Lt; / Pattern & gt; and have to remove it. Suggestion:

  1. Second, how to go:
  & lt; CreateOfficeGroup & gt; & Lt; CreateOfficeName & gt; John & lt; / CreateOfficeName & gt; & Lt; CreateOfficeCode & gt; & Lt; / CreateOfficeCode & gt; & Lt; / CreateOfficeGroup & gt;  

to:

  & lt; CreateOffice Group & gt; & Lt; CreateOfficeName & gt; John & lt; / CreateOfficeName & gt; & Lt; / CreateOfficeGroup & gt;  
  1. As a whole thing? From:
  & lt; CreateOffice Group & gt; & Lt; CreateOfficeName & gt; John & lt; / CreateOfficeName & gt; & Lt; CreateOfficeCode & gt; & Lt; OperatorId> Ve & lt; / OperatorId> & Lt; OfficeCode & gt; 1234 & lt; / OfficeCode & gt; & Lt; CountryCodeLength & gt; 0 & lt; / CountryCodeLength & gt; & Lt; AreaCodeLength & gt; 3 & lt; / AreaCodeLength & gt; & Lt; Properties & gt; & Lt; / Properties & gt; & Lt; ChargeArea & gt; & Lt; / ChargeArea & gt; & Lt; / CreateOfficeCode & gt; & Lt; CreateOfficeSize & gt; & Lt; Chairs & gt; & Lt; / Chairs & gt; & Lt; Tables & gt; & Lt; / Tables & gt; & Lt; / CreateOfficeSize & gt; & Lt; / CreateOfficeGroup & gt;  

to:

  & lt; CreateOffice Group & gt; & Lt; CreateOfficeName & gt; John & lt; / CreateOfficeName & gt; & Lt; CreateOfficeCode & gt; & Lt; OperatorId> Ve & lt; / OperatorId> & Lt; OfficeCode & gt; 1234 & lt; / OfficeCode & gt; & Lt; CountryCodeLength & gt; 0 & lt; / CountryCodeLength & gt; & Lt; AreaCodeLength & gt; 3 & lt; / AreaCodeLength & gt; & Lt; / CreateOfficeCode & gt; & Lt; / CreateOfficeGroup & gt;  

Can you answer the questions as a person? Thanks a lot!

  sed '# 1 hour; 1 $ H: $$ x: Remtag s # \ (\ n * * *) * & lt; \ ([^ & Gt;] * & gt; \) \ (* \ n * *) * & lt; / \ 2 ## gt Remit P} 'Your File  

( - posix

on GOO SAD

  • The empty tag happens.
  • Not an XML parser, something like & lt; tag1 prop = "& lt; tag2 >

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -