未验证 提交 c8d07da9 编写于 作者: O openharmony_ci 提交者: Gitee

!3158 Fix bug convertxml cannot work for release branch

Merge pull request !3158 from hunili/OpenHarmony-3.1-Release
...@@ -40,13 +40,14 @@ Converts an XML text into a JavaScript object. ...@@ -40,13 +40,14 @@ Converts an XML text into a JavaScript object.
- Example - Example
``` ```
var xml = let xml =
'<?xml version="1.0" encoding="utf-8"?>' + '<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' + '<note importance="high" logged="true">' +
' <title>Happy</title>' + ' <title>Happy</title>' +
' <todo>Work</todo>' + ' <todo>Work</todo>' +
' <todo>Play</todo>' + ' <todo>Play</todo>' +
'</note>'; '</note>';
let conv = new convertxml.ConvertXML();
let options = {trim : false, declarationKey:"_declaration", let options = {trim : false, declarationKey:"_declaration",
instructionKey : "_instruction", attributesKey : "_attributes", instructionKey : "_instruction", attributesKey : "_attributes",
textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype", textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
......
...@@ -35,21 +35,26 @@ convert(xml: string, options?: ConvertOptions) : Object ...@@ -35,21 +35,26 @@ convert(xml: string, options?: ConvertOptions) : Object
| 类型 | 说明 | | 类型 | 说明 |
| ------ | ---------------------------- | | ------ | ---------------------------- |
| string | 处理后返回的JavaScript对象。 | | Object | 处理后返回的JavaScript对象。 |
- 示例: - 示例:
``` ```
var xml = let xml =
'<?xml version="1.0" encoding="utf-8"?>' + '<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' + '<note importance="high" logged="true">' +
' <title>Happy</title>' + ' <title>Happy</title>' +
' <todo>Work</todo>' + ' <todo>Work</todo>' +
' <todo>Play</todo>' + ' <todo>Play</todo>' +
'</note>'; '</note>';
var conv = new convertxml.ConvertXML(); let conv = new convertxml.ConvertXML();
var result1 = conv.convert(xml, {trim: false, ignoreDeclaration: false}); let options = {trim : false, declarationKey:"_declaration",
console.log(result1) instructionKey : "_instruction", attributesKey : "_attributes",
textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
nameKey : "_name", elementsKey : "_elements"}
let result = JSON.stringify(conv.convert(xml, options));
console.log(result)
``` ```
...@@ -57,7 +62,7 @@ convert(xml: string, options?: ConvertOptions) : Object ...@@ -57,7 +62,7 @@ convert(xml: string, options?: ConvertOptions) : Object
| 名称 | 参数类型 | 必填 | 说明 | | 名称 | 参数类型 | 必填 | 说明 |
| ----------------- | -------- | ---- | ----------------------------------------------------------- | | ----------------- | -------- | ---- | ----------------------------------------------------------- |
| trim | boolean | | 是否修剪位于文本前后的空白字符,默认false。 | | trim | boolean | | 是否修剪位于文本前后的空白字符,默认false。 |
| ignoreDeclaration | boolean | 否 | 是否忽略xml写入声明指示,默认false。 | | ignoreDeclaration | boolean | 否 | 是否忽略xml写入声明指示,默认false。 |
| ignoreInstruction | boolean | 否 | 是否忽略xml的写入处理指令,默认false。 | | ignoreInstruction | boolean | 否 | 是否忽略xml的写入处理指令,默认false。 |
| ignoreAttributes | boolean | 否 | 是否跨多行打印属性并缩进属性,默认false。 | | ignoreAttributes | boolean | 否 | 是否跨多行打印属性并缩进属性,默认false。 |
...@@ -65,14 +70,14 @@ convert(xml: string, options?: ConvertOptions) : Object ...@@ -65,14 +70,14 @@ convert(xml: string, options?: ConvertOptions) : Object
| ignoreCDATA | boolean | 否 | 是否忽略元素的CDATA信息,默认false。 | | ignoreCDATA | boolean | 否 | 是否忽略元素的CDATA信息,默认false。 |
| ignoreDoctype | boolean | 否 | 是否忽略元素的Doctype信息,默认false。 | | ignoreDoctype | boolean | 否 | 是否忽略元素的Doctype信息,默认false。 |
| ignoreText | boolean | 否 | 是否忽略元素的文本信息,默认false。 | | ignoreText | boolean | 否 | 是否忽略元素的文本信息,默认false。 |
| declarationKey | string | 否 | 用于输出对象中declaration的属性键的名称,默认_declaration。 | | declarationKey | string | 是 | 用于输出对象中declaration的属性键的名称,默认_declaration。 |
| instructionKey | string | 否 | 用于输出对象中instruction的属性键的名称,默认_instruction。 | | instructionKey | string | 是 | 用于输出对象中instruction的属性键的名称,默认_instruction。 |
| attributesKey | string | 否 | 用于输出对象中attributes的属性键的名称,默认_attributes。 | | attributesKey | string | 是 | 用于输出对象中attributes的属性键的名称,默认_attributes。 |
| textKey | string | 否 | 用于输出对象中text的属性键的名称,默认_text。 | | textKey | string | 是 | 用于输出对象中text的属性键的名称,默认_text。 |
| cdataKey | string | 否 | 用于输出对象中cdata的属性键的名称,默认_cdata。 | | cdataKey | string | 是 | 用于输出对象中cdata的属性键的名称,默认_cdata。 |
| doctypeKey | string | 否 | 用于输出对象中doctype的属性键的名称,默认_doctype。 | | doctypeKey | string | 是 | 用于输出对象中doctype的属性键的名称,默认_doctype。 |
| commentKey | string | 否 | 用于输出对象中comment的属性键的名称,默认_comment。 | | commentKey | string | 是 | 用于输出对象中comment的属性键的名称,默认_comment。 |
| parentKey | string | 否 | 用于输出对象中parent的属性键的名称,默认_parent。 | | parentKey | string | 是 | 用于输出对象中parent的属性键的名称,默认_parent。 |
| typeKey | string | 否 | 用于输出对象中type的属性键的名称,默认_type。 | | typeKey | string | 是 | 用于输出对象中type的属性键的名称,默认_type。 |
| nameKey | string | 否 | 用于输出对象中name的属性键的名称,默认_name。 | | nameKey | string | 是 | 用于输出对象中name的属性键的名称,默认_name。 |
| elementsKey | string | 否 | 用于输出对象中elements的属性键的名称,默认_elements。 | | elementsKey | string | 是 | 用于输出对象中elements的属性键的名称,默认_elements。 |
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册