This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Process XML Data
#2
Try this:
Code:
12345678910111213141516171819202122232425262728293031323334
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>]] parameters = {} function starttag(parser, tag, attrs)   if tag == 'Parameter' then     name = attrs.name   end end function text(parser, text)   if name then     parameters[ name ] = text:trim()     name = nil   end end require('lxp').new({   StartElement = starttag,   CharacterData = text, }):parse(xml) log(parameters) log(parameters.UserID)
Reply


Messages In This Thread
Process XML Data - by jamesng - 29.05.2024, 03:31
RE: Process XML Data - by admin - 29.05.2024, 06:30
RE: Process XML Data - by jamesng - 29.05.2024, 11:35

Forum Jump: