xml2lua
xml2lua copied to clipboard
How do I synthesize an xml object that has both attributes and values?
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.