我收到了其他人从数据库中提取的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