29.05.2024, 03:31
Hi
I'm trying to process some XML data and extract the parameter values. For example, the UserID 1234 in the xml below.
xml =[[<?xml version="1.0" encoding="utf-8"?>
<Response>
<Name>Login</Name>
<Parameters>
<Parameter name="Status" dataType="int">0</Parameter>
<Parameter name="StatusMessage" dataType="string">Successful</Parameter>
<Parameter name="UserID" dataType="int">1234</Parameter>
<Parameter name="Firstname" dataType="string">James</Parameter>
<Parameter name="AllowR1XTill" dataType="string">2023-06-30</Parameter>
</Parameters>
</Response>]]
I gather I should be using the following to parse the XML but haven't come across an example of how to implement it. Has anyone done something similar?
require('lxp').new({
StartElement = starttag,
EndElement = endtag,
CharacterData = text,
}):parse(xml)
Many thanks in advance
Kind Regards
James
I'm trying to process some XML data and extract the parameter values. For example, the UserID 1234 in the xml below.
xml =[[<?xml version="1.0" encoding="utf-8"?>
<Response>
<Name>Login</Name>
<Parameters>
<Parameter name="Status" dataType="int">0</Parameter>
<Parameter name="StatusMessage" dataType="string">Successful</Parameter>
<Parameter name="UserID" dataType="int">1234</Parameter>
<Parameter name="Firstname" dataType="string">James</Parameter>
<Parameter name="AllowR1XTill" dataType="string">2023-06-30</Parameter>
</Parameters>
</Response>]]
I gather I should be using the following to parse the XML but haven't come across an example of how to implement it. Has anyone done something similar?
require('lxp').new({
StartElement = starttag,
EndElement = endtag,
CharacterData = text,
}):parse(xml)
Many thanks in advance
Kind Regards
James