diff --git a/en/application-dev/reference/apis/js-apis-convertxml.md b/en/application-dev/reference/apis/js-apis-convertxml.md index e4ffcaa90d6a9ed2c45eff9756ff2e45ae30a2a8..f403580810cb946d98aed4ff2f9808323656e89e 100644 --- a/en/application-dev/reference/apis/js-apis-convertxml.md +++ b/en/application-dev/reference/apis/js-apis-convertxml.md @@ -40,13 +40,14 @@ Converts an XML text into a JavaScript object. - Example ``` - var xml = + let xml = '' + '' + ' Happy' + ' Work' + ' Play' + ''; + let conv = new convertxml.ConvertXML(); let options = {trim : false, declarationKey:"_declaration", instructionKey : "_instruction", attributesKey : "_attributes", textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype", diff --git a/zh-cn/application-dev/reference/apis/js-apis-convertxml.md b/zh-cn/application-dev/reference/apis/js-apis-convertxml.md index 9921f36d03c84b691fdcd0b9bfe993fc4cdad0c0..0e4e1a1c71610ceaca065c396e2f70fc0a7a74fe 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-convertxml.md +++ b/zh-cn/application-dev/reference/apis/js-apis-convertxml.md @@ -35,21 +35,26 @@ convert(xml: string, options?: ConvertOptions) : Object | 类型 | 说明 | | ------ | ---------------------------- | - | string | 处理后返回的JavaScript对象。 | + | Object | 处理后返回的JavaScript对象。 | - 示例: ``` - var xml = + let xml = '' + '' + ' Happy' + ' Work' + ' Play' + ''; - var conv = new convertxml.ConvertXML(); - var result1 = conv.convert(xml, {trim: false, ignoreDeclaration: false}); - console.log(result1) + let conv = new convertxml.ConvertXML(); + let options = {trim : false, declarationKey:"_declaration", + 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 | 名称 | 参数类型 | 必填 | 说明 | | ----------------- | -------- | ---- | ----------------------------------------------------------- | -| trim | boolean | 否 | 是否修剪位于文本前后的空白字符,默认false。 | +| trim | boolean | 是 | 是否修剪位于文本前后的空白字符,默认false。 | | ignoreDeclaration | boolean | 否 | 是否忽略xml写入声明指示,默认false。 | | ignoreInstruction | boolean | 否 | 是否忽略xml的写入处理指令,默认false。 | | ignoreAttributes | boolean | 否 | 是否跨多行打印属性并缩进属性,默认false。 | @@ -65,14 +70,14 @@ convert(xml: string, options?: ConvertOptions) : Object | ignoreCDATA | boolean | 否 | 是否忽略元素的CDATA信息,默认false。 | | ignoreDoctype | boolean | 否 | 是否忽略元素的Doctype信息,默认false。 | | ignoreText | boolean | 否 | 是否忽略元素的文本信息,默认false。 | -| declarationKey | string | 否 | 用于输出对象中declaration的属性键的名称,默认_declaration。 | -| instructionKey | string | 否 | 用于输出对象中instruction的属性键的名称,默认_instruction。 | -| attributesKey | string | 否 | 用于输出对象中attributes的属性键的名称,默认_attributes。 | -| textKey | string | 否 | 用于输出对象中text的属性键的名称,默认_text。 | -| cdataKey | string | 否 | 用于输出对象中cdata的属性键的名称,默认_cdata。 | -| doctypeKey | string | 否 | 用于输出对象中doctype的属性键的名称,默认_doctype。 | -| commentKey | string | 否 | 用于输出对象中comment的属性键的名称,默认_comment。 | -| parentKey | string | 否 | 用于输出对象中parent的属性键的名称,默认_parent。 | -| typeKey | string | 否 | 用于输出对象中type的属性键的名称,默认_type。 | -| nameKey | string | 否 | 用于输出对象中name的属性键的名称,默认_name。 | -| elementsKey | string | 否 | 用于输出对象中elements的属性键的名称,默认_elements。 | \ No newline at end of file +| declarationKey | string | 是 | 用于输出对象中declaration的属性键的名称,默认_declaration。 | +| instructionKey | string | 是 | 用于输出对象中instruction的属性键的名称,默认_instruction。 | +| attributesKey | string | 是 | 用于输出对象中attributes的属性键的名称,默认_attributes。 | +| textKey | string | 是 | 用于输出对象中text的属性键的名称,默认_text。 | +| cdataKey | string | 是 | 用于输出对象中cdata的属性键的名称,默认_cdata。 | +| doctypeKey | string | 是 | 用于输出对象中doctype的属性键的名称,默认_doctype。 | +| commentKey | string | 是 | 用于输出对象中comment的属性键的名称,默认_comment。 | +| parentKey | string | 是 | 用于输出对象中parent的属性键的名称,默认_parent。 | +| typeKey | string | 是 | 用于输出对象中type的属性键的名称,默认_type。 | +| nameKey | string | 是 | 用于输出对象中name的属性键的名称,默认_name。 | +| elementsKey | string | 是 | 用于输出对象中elements的属性键的名称,默认_elements。 | \ No newline at end of file