ARXMLUtils

From Blue Mars Developer Guidebook

Jump to: navigation, search
There are security restrictions on this article

Contents

Overview

ARXMLUtils converts between an XML document and a Lua table. This is useful for REST API on a Web service.

Data Format

XML by Lua table

The format of the table is:

  • element ::= {"tagname", [at={attribute1=value1 [,attribulte2=value2, ...]}][, content]}
  • content ::= {element1 [, element2, ...]} | "string"


Examples

Element without a child

Lua:

{"invoke", at = {name = "showCustomizeWindow", returntype = "xml"}}

XML:

<invoke name="showCustomizeWindow" returntype="xml"/>


Complex element with child nodes

Lua:

{"arguments", {
    {"object", {
        {"property", at = {id = "category"}, {
            {"string", "hair"}}},
        {"property", at = {id = "slot"}, {
            {"string", "head"}}},
        {"property", at = {id = "id"}, {
            {"string", "3"}}},
}}}}

XML:

<arguments>
  <object>
    <property id="category">
      <string>hair</string>
    </property>
    <property id="slot">
      <string>head</string>
    </property>
    <property id="id">
      <string>3</string>
    </property>
  </object>
</arguments>

API

ARXMLUtils.Table2Xml

ARXMLUtils.Table2Xml (table)

Where table is a table in the format described above.

Example:

ARXMLUtils.Table2Xml ({"root", at={at1="123", at2="456"}, {{"child"}}})

ARXMLUtils.Xml2Table

ARXMLUtils.Xml2Table (xml)

Where xml is a string containing an XML element.

Example:

ARXMLUtils.Xml2Table ("<root><child at1='123'/><child/></root>")

Not that single quotations are used for an attribute. Or you can use double quotations escaped with backslashes.

Problems with this wiki page? Contact us either by: Support Email or Support Ticket System

Blue Mars Guidebook Privacy Policy
Blue Mars Guidebook Community Guidelines

Personal tools