Skip to content

How do I synthesize an xml object that has both attributes and values? #101

@Crazyokd

Description

@Crazyokd

with below code:

local people = {
    command_code="Authentication-Information-Request",
    applicationId="3GPP S6a/S6d",
    ["Hop-by-Hop"] = "0x5dd1330b",
    avp = {
        ["Session-Id"] = {
            _attr = {type = "string", vendor = "0"},
        },
    }
}
print("XML Representation\n")
print(xml2lua.toXml(people, "root"))

I can get below result:

XML Representation

<root>
  <Hop-by-Hop>0x5dd1330b</Hop-by-Hop>
  <command_code>Authentication-Information-Request</command_code>
  <applicationId>3GPP S6a/S6d</applicationId>
  <avp>
    <Session-Id>dfslk</Session-Id>
    <Session-Id>
      <vendor>0</vendor>
      <type>string</type>
    </Session-Id>
  </avp>
</root>

But I want synthesize <Session-Id type="string" vendor="0">846</Session-Id>
i tried various method, but all can't work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions