DBから他の人が抽出したXMLファイルを受け取りました。問題は、xmlを正しい方法で読み取るための問題を作成している文字列が含まれていることです。ここでは、そのごく一部です:xmlファイルに空文字列を置き換える
<gmd:fileIdentifier xmlns:gmx="http://www.isotc211.org/2005/gmx">\r\n <gco:CharacterString>0211fa18-e0a4-4d2ed26-7580726e593c</gco:CharacterString>\r\n </gmd:fileIdentifier>\r\n <gmd:language>\r\n <gco:CharacterString>eng</gco:CharacterString>\r\n </gmd:language>\r\n <gmd:hierarchyLevel>\r\n <gmd:MD_ScopeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#MD_ScopeCode" codeListValue="dataset" />\r\n </gmd:hierarchyLevel>\r\n <gmd:contact>\r\n <gmd:CI_ResponsibleParty>\r\n <gmd:organisationName>\r\n <gco:CharacterString>Research</gco:CharacterString>\r\n </gmd:organisationName>\r\n <gmd:contactInfo>\r\n <gmd:CI_Contact>\r\n <gmd:address>\r\n <gmd:CI_Address>\r\n <gmd:electronicMailAddress>\r\n <gco:CharacterString>[email protected]</gco:CharacterString>\r\n </gmd:electronicMailAddress>\r\n </gmd:CI_Address>\r\n </gmd:address>\r\n </gmd:CI_Contact>\r\n </gmd:contactInfo>\r\n
あなたは、各タグの終わりに見ることができるような問題である文字列「\ rを\ nが」があります。 私は、次のbashコマンドを使用してみました:
string='\r\n'
sed -i 's/$string/''/g' test.xml
それが動作していないが、空の文字列は$文字列変数を代入されません。
私が間違っていることを教えていただけますか?
ありがとうございました
お寄せいただきありがとうございます!できます!! –
@ sylar_80、あなたは歓迎です – RomanPerekhrest