!91 Fix bug convertxml cannot work

Merge pull request !91 from hunili/master
This commit is contained in:
openharmony_ci
2022-04-11 07:28:14 +00:00
committed by Gitee
2 changed files with 5 additions and 13 deletions
+1
View File
@@ -315,6 +315,7 @@ namespace OHOS::Xml {
Replace(strXml, "\\r", "\r");
Replace(strXml, "\\n", "\n");
Replace(strXml, "\\v", "\v");
Replace(strXml, "\\t", "\t");
Replace(strXml, "]]><![CDATA", "]]> <![CDATA");
size_t len = strXml.size();
doc = xmlParseMemory(strXml.c_str(), len);
+4 -13
View File
@@ -40,19 +40,8 @@ class ConvertXML {
if (converted.hasOwnProperty('spaces')) {
let space : string | number | undefined = converted.spaces;
delete converted.spaces;
strEnd = JSON.stringify(converted, null, space);
}
let idx : number = 0;
while ((idx = strEnd.indexOf('\\t')) !== -1) {
strEnd = strEnd.substring(0, idx) + '\t' + strEnd.substring(idx + 2);
}
while ((idx = strEnd.indexOf('\\n')) !== -1) {
strEnd = strEnd.substring(0, idx) + '\n' + strEnd.substring(idx + 2);
}
while ((idx = strEnd.indexOf('\\')) !== -1) {
strEnd = strEnd.substring(0, idx) + '' + strEnd.substring(idx + 1);
}
return strEnd;
return converted;
}
}
@@ -142,4 +131,6 @@ function DealLaterReplace(strXml : string, idx : number, idxThir : number)
return strXml;
}
export default ConvertXML
export default {
ConvertXML : ConvertXML
}