convertxml 无法解析 子 tag 中的子 tag element 数据

使用 ‘@ohos.convertxml’ 解析 xml 内容,无法解析到第二层的 tag 数据

xml 数据: 
 
<?xml version="1.0" encoding="GBK"?> 
  <send_confirm_code> 
  <ret code="0" msg="注册成功"/> 
  </send_confirm_code> 
  convertOptions: 
let options: convertxml.ConvertOptions = { 
  trim: true, 
  ignoreDeclaration: true, 
  declarationKey: “_declaration”, 
  instructionKey: “_instruction”, 
  attributesKey: “_attributes”, 
  textKey: “_text”, 
  cdataKey: “_cdata”, 
  doctypeKey: “_doctype”, 
  commentKey: “_comment”, 
  parentKey: “_parent”, 
  typeKey: “_type”, 
  nameKey: “_name”, 
  elementsKey: “_elements” 
} 
解析出来的对象里缺少 send_confirm_code 里的 element 数据
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
HarmonyOS
2024-05-10 22:49:18
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
编程指东

将xml 的 encoding="GBK" 改为 encoding="utf-8", 可以解析send_confirm_code 里的 element 数据 ,目前只支持utf-8编码的xml 文件。

分享
微博
QQ
微信
回复
2024-05-11 11:36:55
相关问题
HarmonyOS AVMuxer如何设置codec tag
745浏览 • 1回复 待解决
HarmonyOS 引入@ohos.nfc.tag
1233浏览 • 2回复 待解决
HarmonyOS 线程获取数据
462浏览 • 1回复 待解决
HarmonyOS TabContent无法套用在组件
1536浏览 • 1回复 待解决
arkTS无法创建窗口有了解吗?
2947浏览 • 0回复 待解决
HarmonyOS stackview无法自由调位置
538浏览 • 1回复 待解决