manoelcampos / xml2lua

XML Parser written entirely in Lua that works for Lua 5.1+. Convert XML to and from Lua Tables šŸŒ–šŸ’±
MIT License
287 stars 73 forks source link

[Question] xml2lua against HTTP SOAP body? #11

Closed jeremyjpj0916 closed 6 years ago

jeremyjpj0916 commented 6 years ago

How will this plugin treat namespaces/case-sensitivity? Take this for example:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
  <soap:Header>
    <wsse:Security>
      <wsse:Username>MyConsumer</wsse:Username>
      <wsse:Userid>33333-33333-33333-33333</wsse:Userid>
    </wsse:Security>
  </soap:Header>
  <soap:Body>
    <searchClaims>
        <firstServiceDate>2015-03-19</firstServiceDate>
        <lastServiceDate>2015-03-19</lastServiceDate>
        <memSuffix>030303</memSuffix>
        <phsNumber>34343</phsNumber>
        <taxId>34525345325435342534523</taxId>
        <subNum>768787688678678768</subNum>
    </searchClaims>
  </soap:Body>
</soap:Envelope>

Could your plugin as it stands today be able to reach the tag for example? Does this plugin support the ability to not only parse but modify as well? For instance if I wanted to get a value but also modify/add an extra element could I (modify the xml and return as a string per say)?

manoelcampos commented 6 years ago

The module creates a table from your XML, keeping tag names as they are, so you don't need to worry. About the namespace, you have to try and open an issue if it doesn't work.

After the module parses the XML, it returns a table inside the handler.root. This way, you can modify it as you wish. If you want to change such a table and get an XML string representation back, you need to use some external module. There is a tableToXml function here (the code documentation is only in Brazilian Portuguese).

jeremyjpj0916 commented 6 years ago

@manoelcampos Thanks for the feedback and suggestions! Much appreciated. Will give this a shot and report back when I have time next few weeks(busy with a lot of workload now so won't be able to play on this for a bit).