我有我試圖使用python使用unix去除嵌入XML文本中的回車
我收到錯誤,偶爾來處理一些XML字符串內文本的xml文件,迫使車廂內返回他們
我如何在UNIX中的XML文本中刪除這些回車,不刪除他們,因爲這將意味着加入所有的XML記錄在一起的XML腳本的
的例子,我可以解析:
一個XML腳本的例子,我無法分析由於回車:
<?xml version="1.0"?><script startAt="2015-03-25T20:59:38Z" sessionId="xyz">
<message attribute= 'hello world, i am going to add a cariage return
right now
even though
i do not have to'></message></script>
我的分析後,最終輸出是要看起來像:
<?xml version="1.0"?><script startAt="2015-03-25T20:59:38Z" sessionId="xyz"><message attribute = 'hello world, i am not going to add a cariage return right now'></message></script>
<?xml version="1.0"?><script startAt="2015-03-25T20:59:38Z" sessionId="xyz"><message attribute= 'hello world, i am going to add a cariage return right now even though i do not have to'></message></script>
我不想要什麼,是要刪除所有回車,因爲我的最終輸出看起來像:
<?xml version="1.0"?><script startAt="2015-03-25T20:59:38Z" sessionId="xyz"><message attribute= 'hello world, i am not going to add a cariage return right now'></message></script><?xml version="1.0"?><script startAt="2015-03-25T20:59:38Z" sessionId="xyz"><message attribute = 'hello world, i am going to add a cariage return right now even though i do not have to'></message></script>
xml.Etree,LXML –
刪除與新行'TR -d「\ n'' –