[JSON].toXMLString()

语法:[JSON].toXMLString()

返回:[String]

说明:将[JSON]实例转换成XML格式结果。

示例:

<%
    jsonString = "{div: 'hello word!'}"    
    Set jsonObj1 = toJson( jsonString )
    Response.Write jsonObj1.toXMLString() ' 输出结果:<div>hello word!</div>
%>

注意:

a) 支持属性格式转换

b) 支持文本节点与子节点共存格式转换

c) 同一父节点下存在多个文本节点时,对应的键名格式为 #text-1、#text-2....

d) 支持数组类型子节点转换

特殊结构转换示例:

    jsonString = "{" &_
                 " 'div': {" &_
                 "   '@id': 'title'," &_
                 "   '#text-1': 'this is Title'," &_
                 "   'ul': { 'li': ['a', 'b', 'c'] }," &_
                 "   '#text-2': 'write date: 2018'" &_
                 "  }," &_
                 "'span': 'this is container'" &_
                 "}"

    Set jsonObj1 = toJson( jsonString )
    Response.Write jsonObj1.toXMLString() 

上例中输出结果为:

<div id="title">
this is Title
<ul>
  <li>a</li>
  <li>b</li>
  <li>c</li>
</ul>
write date: 2018
</div>
<span>this is container</span>

其中键名'@id' 表示属性

#text-1、#text-2表示文本节点

li的数组值表示同胞子节点

 

posted @ 2018-11-18 22:54  1024记忆  阅读(708)  评论(0编辑  收藏  举报